Using interceptors to handle transactions

Transaction processing is used in many applications. However, the implementation of transactions can clutter up business logic. The use of declarative annotations can make transaction processing easier to use. But there are still times when programmatic transaction is necessary such as with long running transactions. When it is, interceptors can be useful.

Getting ready

The essential steps to use interceptors for handling transactions include:

  1. Creating a transaction interceptor
  2. Annotating the target class to use bean-managed transactions
  3. Annotating the target method with the transaction interceptor

    The Handling transactions manually recipe in Chapter 6 explains how to implement bean managed transactions.

How ...

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.