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.
The essential steps to use interceptors for handling transactions include:
- Creating a transaction interceptor
- Annotating the target class to use bean-managed transactions
- Annotating the target method with the transaction interceptor
The Handling transactions manually recipe in Chapter 6 explains how to implement bean managed transactions.