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.
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.
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)?
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.
Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
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 ?