Using the InvocationContext to verify parameters

The InvocationContext interface is used to support information handling within and between interceptors. It is passed as the single argument to a method annotated with the @AroundInvoke annotation. It possesses several methods which can assist in the handling of interceptors. In this recipe we will focus on those methods which provide access to the target method's parameter list and use them to manipulate the parameters.

Getting ready

The basic approach for using an interceptor to validate a target method's parameters involves:

  1. Accessing the target's parameters using the getParameters method
  2. Validating and possibly modifying the parameters
  3. Using the setParameters method to apply any changes to the parameters ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.