Using deployment descriptors for callback interceptors

Lifecycle callback methods are used to perform special processing during the creation, destruction and other events of an EJB. The callback events available are EJB-specific. In this recipe we will examine the use of deployment descriptors to specify a callback event.

Getting ready

The process for creating a deployment descriptor for interceptors includes:

  • Creating an ejb-jar.xml file for the EJB module
  • Using the<interceptors> element to define interceptors
  • Adding a lifecycle element to bind the interceptor to an EJB
  • Deploying the application

To illustrate the use of a deployment descriptor for a lifecycle method, we will modify the RegistrationApplication along with the SimpleInterceptor class ...

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.