Java Reference
In-Depth Information
Documentation on the InvocationContext methods is shown in table 12.3 . This class
provides a wealth of information about the method you're intercepting along with each
method's parameters and other context information.
Table 12.3. Methods on InvocationContext
Method
Description
Object getTarget();
Returns the object instance you're performing interception on
Object getTimer();
Returns the timer object associated with the timeout
Method getMethod();
Returns the method on which you're performing interception
Object[] getParameters();
Returns the parameters that are to be passed to the method
A setter enabling you to change the parameters used to invoke the target meth-
od
void setParameters(Object[] os);
Map<String, Object> getContex-
tData();
Returns context data associated with this invocation—information from the an-
notation
Object proceed() throws Exception;
Proceeds with invoking the method
Once you've defined the interceptor, the next step is to actually use it. You can annotate
either the class or individual methods within a class. To use it on the LandingControl-
ler , you'd add it as follows:
@Named
@ApplicationScoped
@PerformanceMonitor
public class LandingController {
...
}
Adding the annotation to the LandingController doesn't enable it by default. Inter-
ceptors must be enabled in the beans.xml file. The following snippet enables this intercept-
or:
<interceptors>
<class>com.actionbazaar.util.PerformanceInterceptor</class>
</interceptors>
With the interceptor enabled, each method invocation on the LandingController is
tracked. You can annotate other classes as needed. If you're using multiple interceptors,
the order in which they appear within the beans.xml file will determine the order in
which they're executed. Additional interceptors are configured by adding additional
<class></class> elements.
 
Search WWH ::




Custom Search