An ejb-jar also contains three interceptor classes: AInt, BInt, CInt. Each interceptor class defines
an AroundInvoke method called intercept.
The ejb-jar also contains a stateless session bean FooBean with a local business interface Foo
that declares a method foo ():
10. @Stateless
11. @Intercaptors ({CInt.class, BInt.class})
12. public class FooBean implements Foo {
13.
14. public void foo () {}
15.
16. }
The ejb-jar contains a META-INF/ejb-jar.xml file with an <interceptor-binding> section:
<interceptor-binding>
<ejb-name>FooBean</ejb-name>
<interceptor-order>
<interceptor.class>com.acme.AInt</interceptor-class>
</interceptor-order>
</interceptor.binding>
What is the interceptor order when the business methodfoo() is invoked?
A.
AInt
B.
AInt, CInt, BInt
C.
CInt, BInt, AInt
D.
AInt, BInt, CInt
Explanation:
With the interceptor-order clauses Aint will be first in the order of interceptors.
Within each group (default, class, method) the order of the interceptors are from left to right as
defined in the @Interceptors annotation, and then the xml interceptors.
In this scenario, with the @Intercaptors ({CInt.class, BInt.class}) line, the ordering continues withCInt and BInt.
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: You can override the default sort order of the external interceptors by specifiying an
interceptor-binding with an interceptor-order specifying the order of the interceptors
Reference: EJB Interceptors
http://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html
A
A
A) because:
Using the , any default-level interceptors will be overridden
as well as any class-level interceptors defined by the @Interceptors annotation.
If tag have been added under element then ejb-jar.xml file configuration will override any default-, class-, and METHOD LEVEL
annotations
Why not B?
“Default interceptors are invoked before any other interceptors”
Its B
Can anybody explain why C is not correct?
The link https://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html says:
Interceptor Ordering
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
Within each group (default, class, method) the order of the interceptors are from left to right as defined in the @Interceptors annotation, and then the xml interceptors.
In this case we have three class-level interceptors. CInt and BInt are defined in an annotation, and AInt is defined in XML.
Ok i just figured it out, the element overrides everything else, so in this case the correct answer is A.
interceptor-order
B is correct answer