Interceptors are similar to Aspects that allow developers to invoke interceptor methods in conjunction with method invocations or lifecycle events on an associated target class.
Interceptors help eliminate code cluttering and allow implementing of cross-cutting concerns. Interceptors are not as powerful as full AspectJ, but they still provide a great solution for these problem spaces.
To begin we need to assume this code will be run in a CDI-compliant container such as GlassFish. Tomcat does not come with native CDI support.
Before we begin implementing our first interceptor, we first want to cover the various elements and how they interact with one another.
We first start with an object ...