Java Reference
In-Depth Information
Using Multiple Lifecycle Callback Interceptors
Multiple lifecycle interceptors may be defined for a target class by specifying the inter-
ceptor classes in the @Interceptors annotation:
Click here to view code image
@Interceptors({PrimaryInterceptor.class, SecondaryInterceptor.class,
LastInterceptor.class})
@Stateless
public class OrderBean { ... }
The order in which the interceptor classes are listed in the @Interceptors annotation
defines the order in which the interceptors are invoked.
Data stored in the contextData property of InvocationContext is not sharable
across different lifecycle events.
Intercepting Timeout Events
Interceptors for EJB timer service timeout methods may be defined using the
@AroundTimeout annotation on methods in the target class or in an interceptor class.
Only one @AroundTimeout method per class is allowed.
Timeout interceptors have the following form:
Object < method-name >(InvocationContext) throws Exception { ... }
For example:
Click here to view code image
@AroundTimeout
protected void timeoutInterceptorMethod(InvocationContext ctx) { ...
}
Timeout interceptor methods can have public, private, protected, or package-level access,
and must not be declared static or final.
Timeout interceptors can call any component or resource callable by the target timeout
method, and are invoked in the same transaction and security context as the target method.
Timeout interceptors may access the timer object associated with the target timeout meth-
od through the InvocationContext instance's getTimer method.
Search WWH ::




Custom Search