A developer writes three interceptor classes: AInt, BInt, and CInt. Each interceptor class defines
an AroundInvoke method called interceptor. In the ejb-jar.xml descriptor, CInt is declared as the
default interceptor.
FooBean is a stateless session bean with a local business interface Foo that declares a method
Foo ():
10. @Stateless
11. @Interceptors(AInt.class)
12. public class FooBean Implements Foo {
13.
14. @Interceptors (BInt.class)
15. @ExcludeClassInterceptors
16. public void foo () {}
17. }
What is the interceptor order when the business method foo () is invoked?
A.
BInt
B.
CInt, BInt
C.
CInt, AInt, BInt
D.
BInt, AInt, CInt
Explanation:
The default Intercepter, CInt, comes first. The class intercepter AInt is excluded by
@ExcludeClassInterceptors, so the Method Intercepter BInt would be next in order.
Note 1: By default the ordering of interceptors when invoking a method are
* External interceptors
** Default interceptors, if present
** Class interceptors, if present
** Method interceptors, if present
*Bean class interceptor method
Note 2: Annotation Type ExcludeClassInterceptors
Used to exclude class-level interceptors for a business method or timeout method of a target
class.
Reference: EJB Interceptors
http://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html