• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interceptors - more than 1 @AroundInvoke - Multiple @Interceptors declared for a class/method?

 
Ranch Hand
Posts: 49
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens when there are more than one @AroundInvoke methods present in an Interceptor class?
Which one gets executed first?

What happens on invocation of the proceed() method?

Can there be 2 @Interceptors declared for a class or method?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
In section 6.10 of my (free) electronic book, the following can be found on interceptor ordering:


The following specifies the order in which interceptors are invoked. This applies to all the different interceptor types with the corresponding interceptor methods:
• Business methods interceptors – around-invoke methods.
• Timeout method interceptors – around-timeout methods.
• Lifecycle event interceptors – PostConstruct, PreDestroy, PrePassivate, PostActivate methods.

The order in which interceptors are invoked is as follows:
• Default interceptors. Any default interceptors are invoked first in the order in which they are declared in the ejb- jar.xml deployment descriptor.
• Interceptors defined in @Interceptor annotated interceptor classes listed in an @Interceptors annotation on the target EJB class. Such interceptor methods are invoked in the order they are declared in the @Interceptors annotation. Interceptor methods of superclasses to the interceptor classes are invoked first, starting with the most general superclass and traversing down the inheritance hierarchy.
• Interceptors defined in @Interceptor annotated interceptor classes listed in an @Interceptors annotation on the target method in an EJB. Such interceptor methods are invoked in the order they are declared in the @Interceptors annotation annotating the EJB method to be invoked.
Interceptor methods of superclasses to the method-level interceptor classes are invoked first, starting with the most general superclass and traversing down the inheritance hierarchy.
• Interceptor methods defined in the target EJB class. Such interceptor methods are invoked, starting with those defined in the most general superclass and traversing down the inheritance hierarchy until finally invoking the interceptor methods in the target EJB class itself.


Best regards!
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. You can specify just one @AroundInvoke in a class.

2. This method executes intercepted method and returns the type that method returns. If intercepted method return void - it gives you null.

3. They are executed in the order in which they appear.
 
Anirudh Gupta
Ranch Hand
Posts: 49
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Lucas and Ivan.
That was helpful.

I even tried it. 2 @AroundInvoke fails at deployment.
However, I have formed this impression that Weblogic 12C and Glassfish 3.1.1 implementation of Interceptors is not complete,
and what is full of errors. Will shortly post the Error Description and Stack Trace here.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Anirudh Gupta wrote:
However, I have formed this impression that Weblogic 12C and Glassfish 3.1.1 implementation of Interceptors is not complete,
and what is full of errors. Will shortly post the Error Description and Stack Trace here.


I recommend also creating a bug-ticket for the relevant product. I do not know about Weblogic, but GlassFish, being open source, has a JIRA bugtracking system here: http://java.net/jira/browse/GLASSFISH
I have had only good experiences from reporting bugs back to the community.
Best wishes!
 
Seriously? That's what you're going with? I prefer this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic