This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
According to EJB 3.0 Specification core contracts and requirements page no..305 if we've to specify lifecycle callback methods which are written inside an interceptor class for a session bean or mdb using Deployment descriptors then ... we've to use post-construct, pre-destroy, post-activate, and pre-passivate elements.
But when I saw the schema file of ejb-jar.xml for ejb3.0 I did not get these elements or any attribute of such type.
So can you please guide me regarding how do I specify the interceptor class which contains lifecycle callback methods using deployment descriptor.
See.. I don't want to write any lifecycle callback methods inside bean class I want to write it inside interceptor class. And I don't want to use Interceptors annotation on my bean class. I want to specify the interceptor using deployment descriptor.
I understand what you say. Well, in fact I was able to find the around-invoke , pre-passivate and post-activate elements of the deployment descriptor: take a look at page 536. It is defined so that they may be specified inside sessionType or interceptorType elements. But the post-construct and pre-destroy are nowhere to be found.
In fact, inside the definition of the interceptorType element there is a documentation element that reads:
The interceptorType element declares information about a single interceptor class. It consists of : - An optional description. - The fully-qualified name of the interceptor class. - An optional list of around invoke methods declared on the interceptor class and/or its super-classes. - An optional list environment dependencies for the interceptor class and/or its super-classes. - An optional list of post-activate methods declared on the interceptor class and/or its super-classes. - An optional list of pre-passivate methods declared on the interceptor class and/or its super-classes.
Again, the post-construct and pre-destroy elements are not mentioned.
This is not what the specification states in section 12.4:
If the deployment descriptor is used to deﬁne interceptors, the post-construct, pre-destroy, post-activate, and pre-passivate elements are used.
Furthermore, section 12.8.1 makes the following "mistake":
The interceptor methods are speciﬁed by using the around-invoke, pre-construct, post-destroy, pre-passivate, and post-activate elements.
Note it talks about pre-construct (vs. post-construct) and post-destroy (vs. pre-destroy).
This is confusing. [ September 01, 2008: Message edited by: Sergio Tridente ]