Griffon
  1. Griffon
  2. GRIFFON-317

Services could be auto registered as app event listeners

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.2-beta-3
    • Fix Version/s: 0.9.2-rc1
    • Component/s: rt
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Services are treated as singletons and automatically instantiated on demand. This may result in a bit of verbosity to have a service be an app event listener. Given that Services are already managed by the framework they should probably be registered automatically as app event listeners too.

        Activity

        Hide
        Justin Nauman added a comment -

        If you don't mind explaining what your current work around is, I would appreciate it. I am currently registering my main controller, which holds a reference to the service, as a listener for the onShutdownStart event.

        Once I receive that notification I call a public method on the service instance to shutdown GPars threadpools, disconnect from data sources, etc.

        Does that seem appropriate? I couldn't figure out how to get a handle to the service in the Events.groovy via the app reference.

        Show
        Justin Nauman added a comment - If you don't mind explaining what your current work around is, I would appreciate it. I am currently registering my main controller, which holds a reference to the service, as a listener for the onShutdownStart event. Once I receive that notification I call a public method on the service instance to shutdown GPars threadpools, disconnect from data sources, etc. Does that seem appropriate? I couldn't figure out how to get a handle to the service in the Events.groovy via the app reference.
        Hide
        Andres Almiray added a comment -

        What you're doing right now is precisely what can be done for the moment. Service instances are not kept in a Map/List provided by the application as the other MVC members are (due to their singleton nature).

        Once this feature is finished, you'll be able to define app event handlers on a Service. Bear in mind that services are instantiated lazily which means they won't be able to react to early app events like BootStrapEnd or StartupStart for example.

        Show
        Andres Almiray added a comment - What you're doing right now is precisely what can be done for the moment. Service instances are not kept in a Map/List provided by the application as the other MVC members are (due to their singleton nature). Once this feature is finished, you'll be able to define app event handlers on a Service. Bear in mind that services are instantiated lazily which means they won't be able to react to early app events like BootStrapEnd or StartupStart for example.

          People

          • Assignee:
            Andres Almiray
            Reporter:
            Andres Almiray
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: