O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Getting ready

There are two major steps in the creation and use of an interceptor:

  1. Creating a class containing an @AroundInvoke annotated method
  2. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required