Using lifecycle methods in interceptors
Methods marked with annotations such as @PreDestroy and @PostConstruct are lifecycle methods. They are invoked during various phases in the lifecycle of an EJB. The @PrePassivate and @PostActivate annotations are also life cycle methods for stateful session beans. Each EJB type has a different set of lifecycle events. These lifecycle methods can also be used in interceptors.
We will be reusing the
SimpleInterceptor class as defined in the Defining and using interceptors recipe. In this recipe, we will add a @PostConstruct annotation to illustrate the incorporation of lifecycle methods.
How to do it...
SimpleInterceptor and add a
constructed method annotated with @PostConstruct. In ...