Defining and using interceptors
In this recipe, we will examine the process of creating and using a simple interceptor. An interceptor method will be invoked before a target method is executed. When the target method returns, additional code within the interceptor can be executed. This approach is useful for performing orthogonal tasks and for manipulating the parameters sent to a method and/or returned from a method.
There are two major steps in the creation and use of an interceptor:
- Creating a class containing an @AroundInvoke annotated method
- Specifying the target method using the @Interceptors annotation
To use an interceptor, we must first create it and then specify where it will be used. The @AroundInvoke annotation designates ...