Hi everyone,
I'm trying to use interceptor bindings with @Schedule methods but it
does not seem to work.
It works with the classic @Interceptor(SomeInterceptor.class) but not
with @SomeInterceptorBinding.
The interceptor bean is declared in the beans.xml and the interceptor
binding works fine with @Timeout methods but not around @Schedule
methods (aroundTimeout).
Here is the code I use:
-------------------------------
@Startup
@Singleton
@Metrology
public class Test implements Serializable {
private static final long serialVersionUID = -254310325908151372L;
@Resource
TimerService timerService;
@PostConstruct
public void init() {
System.out.println("startup");
timerService.createTimer(0, 10000, null);
}
@Schedule(second = "0/5", minute = "*", hour = "*")
void schedule() {
System.out.println("schedule()");
}
@Timeout
public void timeOut() {
System.out.println("timeOut()");
}
}
-------------------------------
@Inherited
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE })
public @interface Metrology {
}
-------------------------------
@Metrology
@Interceptor
public class MetrologyBean implements Serializable {
private static final long serialVersionUID = 1L;
@AroundInvoke
@AroundTimeout
public Object metrology(InvocationContext invocationContext) throws
Exception {
System.out.println("aroundTimeout() " +
invocationContext.getMethod().getName());
return invocationContext.proceed();
}
}
Here is what is displayed in the Glassfish console :
-------------------------------
INFO: aroundTimeout() timeOut
INFO: timeOut()
INFO: schedule()
INFO: schedule()
INFO: aroundTimeout() timeOut
INFO: timeOut()
-------------------------------
There is no : INFO: aroundTimeout() schedule.
Is this a bug ? Are the interceptor bindings not supported for @Schedule
methods ? I can't seem to find any related information about this issue.
Thanks for your help.
Regards,
Sergio