5.4. Life cycle methods
Session bean and entity bean Seam components support all common EJB3 life cycle callbacks (
@PostConstruct
, @PreDestroy
, etc.), but Seam also supports the use of any of these callbacks with JavaBean components. However, since these annotations are not available in a J2EE environment, Seam defines two additional component life cycle callbacks, equivalent to @PostConstruct
and @PreDestroy
.
The
@Create
method is called after Seam instantiates a component. Components may define only one @Create
method.
The
@Destroy
method is called when the context that the Seam component is bound to ends. Components may define only one @Destroy
method.
In addition, stateful session bean components must define a method with no parameters, annotated
@Remove
. This method is called by Seam when the context ends.
Finally, the
@Startup
annotation can be applied to any application- or session-scoped component. The @Startup
annotation tells Seam to instantiate the component immediately, when the context begins, instead of waiting until it is first referenced by a client. It is possible to control the order of instantiation of start up components by specifying @Startup(depends={....})
.