Creating your own interceptor

Interceptors can be configured to execute before and after a method is executed. This permits moving orthogonal functionality out of the method thus reducing the complexity and clutter of the method. As we have seen in previous chapters, interceptors have been used for a variety of tasks such as handling transactions and security. In this recipe, we will demonstrate the technique for creating our own interceptors to meet any unique requirements of our application.

Getting ready

The process to create and use an interceptor involves:

  1. Creating an interceptor binding to define the characteristics of the interceptor
  2. Implementing the interceptor class
  3. Adding the interceptor to the application

    An interceptor binding is used to ...

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.