Session bean and entity bean Seam components support all the usual EJB 3.0 lifecycle callback (@PostConstruct
, @PreDestroy
, etc). Seam extends all of these callbacks except @PreDestroy
to JavaBean components. But Seam also defines its own component lifecycle callbacks.
The @Create
method is called every time Seam instantiates a component. Unlike the @PostConstruct
method, this method is called after the component is fully constructed by the EJB container, and has access to all the usual Seam functionality (bijection, etc). 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. Stateful session bean components
must
define a method annotated @Destroy @Remove
.
Finally, a related annotation is the @Startup
annotation, which may 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 startup components by specifying @Startup(depends={....})
.