Java Reference
In-Depth Information
...
}
Intercepting Method Invocations
The @AroundInvoke annotation is used to designate interceptor methods for managed
object methods. Only one around-invoke interceptor method per class is allowed. Around-
invoke interceptor methods have the following form:
Click here to view code image
@AroundInvoke
visibility Object method-name (InvocationContext) throws Exception { ... }
For example:
Click here to view code image
@AroundInvoke
public void interceptOrder(InvocationContext ctx) { ... }
Around-invoke interceptor methods can have public, private, protected, or package-level
access, and must not be declared static or final.
An around-invoke interceptor can call any component or resource callable by the target
method on which it interposes, have the same security and transaction context as the target
method, and run in the same Java virtual machine call-stack as the target method.
Around-invoke interceptors can throw any exception allowed by the throws clause of the
target method. They may catch and suppress exceptions, and then recover by calling the
InvocationContext.proceed method.
Using Multiple Method Interceptors
Use the @Interceptors annotation to declare multiple interceptors for a target method
or class.
Click here to view code image
@Interceptors({PrimaryInterceptor.class, SecondaryInterceptor.class,
LastInterceptor.class})
public void updateInfo(String info) { ... }
The order of the interceptors in the @Interceptors annotation is the order in which
the interceptors are invoked.
Search WWH ::




Custom Search