Using deployment descriptor for default interceptors

Default interceptors are intended to be executed for every session and message-driven EJB in the EJB module. However, default interceptors can only be declared within the ejb-jar.xml deployment descriptor. This recipe will illustrate this technique.

Getting ready

The process for creating a deployment descriptor for default interceptors includes:

  1. Creating an ejb-jar.xml file for the EJB module
  2. Using the<interceptors> element to define your interceptors
  3. Adding an<interceptor-binding> element to bind the interceptor to an EJB
  4. Deploying the application

The basic structure of the XML elements is as follows:

<interceptors> <interceptor> <interceptor-class>interceptorClass</interceptor-class> </interceptor> ...

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.