Java Reference
In-Depth Information
public class AroundConstructInterceptor {
private Logger logger =
Logger.getLogger("AroundConstructInterceptor.interceptorClass");
@AroundConstruct
public Object initialize(InvocationContext
ctx) throws Exception{
logger.info("initialize - constructor
:"+ctx.getConstructor()+", "
+ "parameters :
"+Arrays.toString(ctx.getParameters())+","
+ " execution time : "+new Date());
return ctx.proceed();
}
}
@Stateless
@Interceptors(AroundConstructInterceptor.class)
public class AroundConstructBean {
private Logger logger =
Logger.getLogger("AroundConstructManagedBean.interceptorClass");
public AroundConstructBean(){
logger.info("AroundConstructManagedBean -
Execution time :"+new Date());
}
}
Associating an interceptor with a class using interceptor
binding
Associating Interceptors using Interceptor Bindings
, Chapter 3 of the
Interceptors
1.2 Specification Document
, was extracted from Chapter 9 of the
CDI Specification
Document
. It discusses the possibility of using annotations to associate interceptors
with another component that is not an interceptor. To make this possible you must: