• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with EJB 3.0 Specs Intercptors ......

 
Nitin Takale
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.

So how to do it ???

thanks

Nitin
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitin,

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 define 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 specified 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 ]
 
Nitin Takale
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks....Sergio Tridente

But I got the solution for the same... I used Eclipse Ganymede and here goes the ejb-jar.xml of it.....


<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>WorkerBean</ejb-name>
<business-remote>com.seed.WorkerBeanRemote</business-remote>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>

</enterprise-beans>

<interceptors>

<interceptor>

<interceptor-class>com.seed.interceptor.LifeCycleInterceptor</interceptor-class>

<post-construct>

<lifecycle-callback-method>oneMoreCreate</lifecycle-callback-method>
</post-construct>
<pre-destroy>

<lifecycle-callback-method>oneMoreDestroy</lifecycle-callback-method>
</pre-destroy>
</interceptor>
</interceptors>
<assembly-descriptor>

<interceptor-binding>

<ejb-name>WorkerBean</ejb-name>

<interceptor-class>com.seed.interceptor.LifeCycleInterceptor</interceptor-class>

</interceptor-binding></assembly-descriptor>

</ejb-jar>


Well that's the way it is ....

bye

nitin
 
Tomaszz Lewandowski
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

<post-construct> and <pre-destroy> elements are in jndiEnvironmentRefsGroup in interceptorType, so the spec is correct, you can use these as subelements of element "interceptor" and "session".
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic