This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how many interceptor method in a Bean class ?

 
Sanju Thomas
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • 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.


 
Deepika Joshi
Ranch Hand
Posts: 268
  • 0
  • Mark post as helpful
  • send pies
  • 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)?
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic