Startup Singleton - mareknovotny/seam-migration GitHub Wiki
Seam 2 provides the @Startup annotation that can be applied to an
application or session scoped component. A
@Startup annotated component is instantiated immediately
after the context is started up, instead of instantiating the component
lazily when first needed by a client.
There are several alternatives in Java EE 6:
-
EJB Singleton beans which can be marked to be instantiated eagerly at application startup using the @Startup annotation. Combined with the fact that these components can benefit from declarative transaction management, these components are good candidates for performing database imports, etc.
-
Observing CDI’s 1.1+ built-in events which notify the component when the application starts or when the request or session context is activated due to a servlet request.
-
Observing initialization of the
ServletContextusing the DeltaSpike Servlet module:@Observes @Initialized ServletContext