Java Reference
In-Depth Information
return ctx.proceed();
}
@Schedule(minute="*/2", hour="*")
public void executeEvery2Second(){
logger.info("executeEvery2Second -
executeEvery5Second - date: "+new Date());
}
@AroundTimeout
public Object
targetClassTimerInterceptor(InvocationContext
ctx) throws Exception{
logger.info("targetClassTimerInterceptor -
method :"+ctx.getMethod().getName()+", timer :
"+ctx.getTimer());
return ctx.proceed();
}
}
Defining interceptors in an interceptor class
The following code shows a class that can be used as an interceptor. To complete
this class, we extract the interceptor methods contained in the StudentSes-
sionBean class. As you can see, this class has no special annotation. But to be
explicit, you can decorate it with javax.interceptor.Interceptor annotation
(in our case, we have not done it to show you that this is optional).
public class MyInterceptor {
private Logger logger = Logger.getLogger(
"studentSessionBean.targetClassInterceptor");
@AroundInvoke
public Object
targetClassMethodInterceptor(InvocationContext
ctx) throws Exception{
Search WWH ::




Custom Search