Services are singletons that have pluggable implementation and can participate in Turbine startup and shutdown.
What is a service?
The life cycle of a ServiceA Service is not supposed to do much in it's constructor. Especialy it should not allocate any costly resources like large memory structures, DB or network connections and the like. It may well happen that the Service is sitting in the config file, but the application does not need it, so allocating all resources at system startup might be a loss. Better explanation of early initialization. WebMacro is no longer a service and what was currently here is misleading. Late initialization happens when the Service is requested by the application for the first time. It should allocate any resources needed and chnge the state so that getInit() returns true. If getInit() returns false after init() is executed, the Service has malfunctioned. After late initialization, the Service is ready to perform actions on behalf of the application. When the Service is no longer needed (this usually happens when system is shutting down), the shutdown() method is called. shutdown() should deallocate all resources. If any error conditions occur they are ignored. |