• 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

how many interceptor method in a Bean class ?

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Section 12.3 of the EJB core specs says that we can have only one @AroundInvoket method in a class.


AroundInvoke methods may be defined on superclasses of the bean class or interceptor classes.
However, only one AroundInvoke method may be present on a given class. An AroundInvoke
method cannot be a business method of the bean.



But I could write two AroundInvoke methods in the Bean class, and JBoss 5.0 did not complain anything about it!.

Code is gien below.

Remote interface


Bean Class




Client code



JBoss console output
------------------------

13:01:16,381 INFO [STDOUT] interceptorMethod is called
13:01:16,381 INFO [STDOUT] interceptorMethodOne is called
13:01:16,381 INFO [STDOUT] Business Method
13:01:16,427 INFO [STDOUT] interceptorMethod is called
13:01:16,427 INFO [STDOUT] interceptorMethodOne is called
13:01:16,427 INFO [STDOUT] Business method one


Whats happening here ?? Am I doing something wrong ? or JBoss is not following spec ? Both interceptor methods are permitted and both are getting executed. Please help.


 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the following code from EJB 3 In Action
When you use @Interceptors you mention class name (e.g. ActionBazaarLogger.class) (and not method name),
If you have more than one @AroundInvoke in a class then how would you use them (or either of them)?
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the specifications provided by SUN says that you must have only one method in an interceptor taged with the @AroundInvoke annotation, however it seems that JBoss didn't follow this specification. many times Applicatin Servers modifiy a bit some of the specifications.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The spec says "However, only one AroundInvoke method may be present on a given class. ", not "must be", which also means : "You're responsible for your mistakes"

Here is what Glassfish gave me :



You can see that only one interceptor method is called. I also tried to put the interceptor method in a separate class :


This time, it gave me :
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Test result from Glasfish is also strange. When we had @AroundInvoke interceptor methods inside the bean the "interceptorMethodOne" got invoked, when we moved to a seperate interceptor class the "interceptorMethod" got invoked.

anyways what should I answer for the exam ?

According to spec we can have only one @AroundInvoke method in a class. Whether its in bean class or in sperate interceptor class. is that correct ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

anyways what should I answer for the exam ?


Only one method allowed in the same class.
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christophe.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic