I need to stop and start all methods annotated with @Schedule in my EJBs classes.
For example I would like to stop and after few minutes restart doIt() method in that EJB class :
@Stateless
public class MySchedule {
@Schedule(second = "*/15", minute = "*", hour = "*", persistent = false)
public void doIt(){
// do anything ...
}
}
I tried to use EJB Interceptors , like this code :
@Stateless
public class MySchedule {
@Schedule(second = "*/15", minute = "*", hour = "*", persistent = false)
@Interceptors(MyInterceptor.class)
public void doIt(){
// do anything ...
}
}
public class MyInterceptor{
@AroundInvoke
public Object intercept(){
System.out.println(" Schedule Intercepted");
Object result = context.proceed();
}
}
But intercept method never fired by @Schedule