Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB 3.1 - interceptors ordering and binding definition

 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ranchers!

Just want to make sure I got it right:

1. Can I define the interceptors ordering using annotations in my EJB's?

I know I can make it in the DD like this:



So, the order of interceptors will be the order of their declaration in DD, so the INTERCEPTOR_1 will run before INTERCEPTOR_2 for the following DD:



2. And this order affects only the EJB I specified in <ejb-name>?
3. So this is not the application-wide ordering of interceptors, but just the ordering for this particular EJB?

4. If I understood the EJB-JAR DD (http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd), there can be only <interceptor-order> element which consists of <interceptor-class> OR <interceptor-class> directly as a sibiling of <ejb-name>. They cannot exist at the same time?

Thanks in advance for your time and help!

Cheers!
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, that's weird - I'm talking to myself :-)

Sorry for this question - thanks to Enthuware I just had a question about the annotation ordering of interceptors and the answer is quite simple:

http://download.oracle.com/javaee/6/api/javax/interceptor/Interceptors.html
Javadoc wrote:Declares an ordered list of interceptors for a target class or method of a target class.


So the @Interceptors({ValidationInterceptor.class, SecurityInterceptor.class}) will run the ValidationInterceptor followed by the SecurityInterceptor.

It's worth of notice that the standard ordering of interceptor levels is still valid (firstly the default ones will run, then class level, method level and @AroundInvoke in the bean class in the end).

Hope it will help someone, someday :-)

Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!