This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<method> in ejb-jar deployment descriptor.

 
Mellon Sun
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the O'REILLY's book Enterprise JavaBeans 3.0, the descriptor samples do not use method element.

<ejb-jar>
...
<assembly-descriptor>
<interceptor-binding>
<ejb-name>TravelAgentBean</ejb-name>
<interceptor-class>...</interceptor-class>
<method-name>bookPassage</method-name>
<method-params>
<method-param>...</method-param>
<method-param>...</method-param>
</method-params>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>

I tried my own descriptor like the above but encountered an error. Affter I looked up http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd, I got that there is an method element enclosing the method-name and method-params needed.

I thought it is a miss before I read same snippet in Mikalai Zaikin's study guide:

<interceptor-binding>
<ejb-name>...
<interceptor-class>...
<method-name>...
<method-params>...
</interceptor-binding>

After all, there is little chance two different writers make one same mistake. Anyboy know this exactly?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your samples the "method" element is needed. See core spec page 519, 520 for the schema and four very nice examples.
 
Tomaszz Lewandowski
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that specification is self-contradicting in this case, because in the deployment descriptor schema there is a "method" element, but in chapter 12, the specification gives bad example:

<interceptor-binding>
<ejb-name>EmployeeService</ejb-name>
<interceptor-class>org.acme.MyIC</interceptor-class>
<method-name>myMethod</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</interceptor-binding>
 
Mellon Sun
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in "JSR 220: Enterprise JavaBeansTM,Version 3.0 EJB Core Contracts and Requirements", there are conflicts about this topic.

Page 312-313:

There are four possible styles of the interceptor element syntax:
Style 1:
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
</interceptor-binding>
Specifying the ejb-name element as the wildcard value "*" designates default interceptors (interceptors
that apply to all enterprise beans contained in the ejb-jar).
Style 2:
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
</interceptor-binding>
This style is used to refer to interceptors associated with the specified enterprise bean class (class-level
interceptors).
Style 3:
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
<method-name>METHOD</method-name>
</interceptor-binding>
This style is used to associate a method-level interceptor with the specified method of the specified
enterprise bean. If there are multiple methods with the same overloaded name, the element of this style
refers to all the methods with the overloaded name. Method-level interceptors can only be associated
with business methods of the bean class. Note that the wildcard value "*" cannot be used to specify
method-level interceptors.
Specification of Interceptors in the Deployment DescriptorEnterprise JavaBeans 3.0, Final Release Interceptors

Style 4:
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
<method-name>METHOD</method-name>
<method-params>
<method-param>PARAM-1</method-param>
<method-param>PARAM-2</method-param>
...
<method-param>PARAM-n</method-param>
</method-params>
<interceptor-binding>

And in page 519-520:

There are four possible styles of the interceptor element syntax :
1.
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
</interceptor-binding>
Specifying the ejb-name as the wildcard value "*" designates
default interceptors (interceptors that apply to all session and
message-driven beans contained in the ejb-jar).
2.
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
</interceptor-binding>
This style is used to refer to interceptors associated with the
specified enterprise bean(class-level interceptors).
3.
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
<method>
<method-name>METHOD</method-name>
</method>
</interceptor-binding>
This style is used to associate a method-level interceptor with
the specified enterprise bean. If there are multiple methods
with the same overloaded name, the element of this style refers
to all the methods with the overloaded name. Method-level
interceptors can only be associated with business methods of the
bean class. Note that the wildcard value "*" cannot be used
to specify method-level interceptors.
4.
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
<method>
<method-name>METHOD</method-name>
<method-params>
<method-param>PARAM-1</method-param>
<method-param>PARAM-2</method-param>
...
<method-param>PARAM-N</method-param>
</method-params>
</method>
</interceptor-binding>
 
Mellon Sun
Ranch Hand
Posts: 126
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In GlassFish V2 and NetBean6.5, the prior one with no <method> element doesn't work. So, it is clear now. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic