Understanding interceptors
Interceptors are defined as part of the EJB 3.1 specification (JSR 318), and are used to intercept Java method invocations and lifecycle events that may occur in Enterprise Java Beans (EJB) or Named Beans from Context Dependency Injection (CDI).
The three main components of interceptors are as follows:
The Target class: This class will be monitored or watched by the interceptor. The target class can hold the interceptor methods for itself.
The Interceptor class: This interceptor class groups interceptor methods.
The Interceptor method: This method will be invoked according to the lifecycle events.
As an example, a logging interceptor will be developed and integrated into the Store application. Following the hands-on approach of this book, we will see how to apply the main concepts through the given examples without going into a lot of details.
Note
Check the Web Resources section to find more documentation about interceptors.
Creating a log interceptor
A log interceptor...