Grails
  1. Grails
  2. GRAILS-8824

Allow AbstractPersistenceEventListener to be set with a null datasource

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      All

      Description

      Currently, you need to pass in a datasource into AbstractPersistenceEventListener constructor, otherwise a NullPointerException is raised.

      The documentation states that you should be able to just add a listener without a datasource.

      def init =

      { applicationContext.addApplicationListener(new MyPersistenceListener()) }

      This case should be supported.

        Activity

        Hide
        Aaron Long added a comment -

        As a workaround, you can get the list of datastores out of the application context using:

        grailsApplication.mainContext.eventTriggeringInterceptor.datastores

        Show
        Aaron Long added a comment - As a workaround, you can get the list of datastores out of the application context using: grailsApplication.mainContext.eventTriggeringInterceptor.datastores
        Hide
        Graeme Rocher added a comment -

        You'd be better off with "applicationContext.getBeansOfType(Datastore)"

        Show
        Graeme Rocher added a comment - You'd be better off with "applicationContext.getBeansOfType(Datastore)"

          People

          • Assignee:
            Unassigned
            Reporter:
            Tomas Lin
          • Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:

              Development