Java Reference
In-Depth Information
The i rst part of the XML i le lists the interceptors; then the interceptor bindings need to be
declared. This is done in the assembly description part, which can accept a wildcard (*) that applies
to all or a specii c name to create the binding between the interceptors and the EJB. The order of the
interceptors listed also determines the execution order. The interceptors listed in the EJB‐JAR i le
apply only to EJB in the same module.
Interceptor Order
If more than one interceptor has been defined for an advice, the order of the execution will
be from the most general to the most specific case. This means that default‐level interceptors
will be executed before class‐level interceptors, which will be followed by method‐level
interceptors.
This behavior is expected; nevertheless, the order of same‐level interceptors can be a bit more
confusing. If there is more than one default‐level interceptor, the order in the EJB‐JAR i le
determines the order of the execution of the interceptors.
<ejb-jar...>
<interceptors>
<interceptor>
<interceptor-class>
com.devchronicles.SecurityInterceptor
</interceptor-class>
<interceptor‐class>
com.devchronicles.AnotherInterceptor
</interceptor‐class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>OrderBean</ejb-name>
<interceptor-order>
<interceptor-class>
com.devchronicles.SecurityInterceptor
</interceptor-class>
</interceptor-order>
<interceptor‐class>
com.devchronicles.AnotherInterceptor
</interceptor‐class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
When there is more than one class‐level interceptor, the interceptors follow the order in which they
are listed in the @Interceptors annotation:
@Interceptors(SecurityInterceptor.class, AnotherInterceptor.class )
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class SomeBusinessService {
public void startService(){
// ...
 
Search WWH ::




Custom Search