Java EE Interceptors
Technology to do method call intercept. Common uses of interceptors are logging, auditing, and profiling.
target class – class in which Interceptors are defined. Interceptor methods are invoked in conjunction with the methods (of target class) or lifecycle events of the target class.
interceptor method – methods which handles the interceptor invocation. It could be defined in target class as interceptor method or defined in separate class called interceptor class.
interceptor class – contains interceptor methods
Interceptor Metadata Annotations
|Interceptor Metadata Annotation||Description|
|javax.interceptor.AroundInvoke||Designates the method as an interceptor method.|
|javax.interceptor.AroundTimeout||Designates the method as a timeout interceptor, for interposing on timeout methods for enterprise bean timers.|
|javax.annotation.PostConstruct||Designates the method as an interceptor method for post-construct lifecycle events.|
|javax.annotation.PreDestroy||Designates the method as an interceptor method for pre-destroy lifecycle events.|
- JSR 318: Enterprise JavaBeans 3.1 (includes Interceptors 1.1 specification)