(Quick Reference)

8.2.1 Service Lifecycle - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

8.2.1 Service Lifecycle

Services participate in a lifecycle as they are automatically managed by the application. The GriffonService interface defines a pair of methods that every service may override.

public interface GriffonService extends GriffonArtifact {
    void serviceInit();
    void serviceDestroy();
}

The first one is called immediately after the service has been instantiated by the ServiceManager. This is the right place to put initialization code. The app instance should be already set on the service instance, giving you direct access to the application's configuration and i18n facilities.

The second method is also called by ServiceManager when the application is shutting down. Be aware that this method will be called before MVC groups are destroyed.