• 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

interceptors in the EJB 3.0 ejb-jar.xml

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I just stumbled into something while learning for my SCBCD5 beta exam.

I downloaded the EJB3 specs from jcp.org. According to these specs the declaration of interceptors in the ejb-jar.xml deployment descriptor should look something like this:


But when I look at the XSD-file from Sun , the definition of the same interceptor comes down to something like this:



Both seem to originate from a very reliable source (JCP and Sun).
Does anybody know which one is right?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One is for applying your interceptor to a particular bean using dd.You are applying myInterceptor to interceptorfoo method on bean FooBean.The other one is to inject dependencies into interceptor class itself.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, both are correct.

1. In the first style of dd, you dont have an option to specify any resource references (or, dependency injection).
2. Second style allows to specify that in the dd itself. The following example will support the point:

interceptors>
<interceptor> <interceptor-class>org.jboss.tutorial.interceptor.bean.AccountsCancelInterceptor</interceptor-class>
<around-invoke-method>
<method-name>sendCancelMessage</method-name>
</around-invoke-method>
<resource-ref>
<res-ref-name>jms/ConnFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<mapped-name>java:/ConnectionFactory</mapped-name>
<injection-target>
<injection-target-class>org.jboss.tutorial.interceptor.bean.AccountsCancelInterceptor</injection-target-class>
<injection-target-name>cf</injection-target-name>
</injection-target>

</interceptor>
</interceptors>
 
Jaap Coomans
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! I'm still not sure why both options don't occur in both sources, but at least I know they're both right.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks, hi Jaap,

This thread might be dead for years. But I am currently preparing myself for the SCBCD 5 exam and I was confused by Jaaps question, too.
So here are my 5 cents to this.

The first deployment descriptor snippet of Jaaps initial question applies the interceptor class "MyInterceptor" to the method with the signature "interceptFoo(String)" of the bean named "FooBean". The corresponding metadata annotation could look like this:

The method name "interceptFoo" is a little bit misleading in this example. It might have be named "anyMethod" because it is the method which is to be intercepted. And, there is a enclosing "method" element missing in the snippet. It is expected to embrace the elements "method-name" and "method-params".

The secondond deployment descriptor snippet declares the method named "interceptFoo" of the class "MyInterceptor" to be an around-invoke interception method. The "method-params" element is not legal in this context since any around-invoke interception method is expected to have the signature "Object <any-method-name>(InvocationContext) throws Exception".

The corresponding metadata annotation might look like this:

I hope this of help to somebody.

Rock on,
Dirk
 
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