• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

<method> in ejb-jar deployment descriptor.

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic