Java Reference
In-Depth Information
Multiple interceptors may also be defined in the deployment descriptor. The order of the
interceptors in the deployment descriptor is the order in which the interceptors will be in-
voked.
Click here to view code image
...
<interceptor-binding>
<target-name>myapp.OrderBean</target-name>
<interceptor-class>myapp.PrimaryInterceptor.class</interceptor-
class>
<interceptor-
class>myapp.SecondaryInterceptor.class</interceptor-class>
<interceptor-class>myapp.LastInterceptor.class</interceptor-
class>
<method-name>updateInfo</method-name>
</interceptor-binding>
...
To explicitly pass control to the next interceptor in the chain, call the InvocationCon-
text.proceed method.
Data can be shared across interceptors:
• The same InvocationContext instance is passed as an input parameter to
each interceptor method in the interceptor chain for a particular target method.
The InvocationContext instance's contextData property is used to pass
data across interceptor methods. The contextData property is a
java.util.Map<String, Object> object. Data stored in contextData
is accessible to interceptor methods further down the interceptor chain.
• The data stored in contextData is not sharable across separate target class
method invocations. That is, a different InvocationContext object is created
for each invocation of the method in the target class.
Accessing Target Method Parameters From an Interceptor Class
The InvocationContext instance passed to each around-invoke method may be used
to access and modify the parameters of the target method. The parameters property
of InvocationContext is an array of Object instances that corresponds to the
parameter order of the target method. For example, for the following target method, the
parameters property, in the InvocationContext instance passed to the around-
invoke interceptor method in PrimaryInterceptor , is an Object array containing
two String objects ( firstName and lastName ) and a Date object ( date ):
Search WWH ::




Custom Search