Hi,
I wrote a class:
public class PnaScheduleFacade implements SessionBean, TimedObject { public void ejbTimeout(Timer arg0) { // task code. } public TimerHandle createTimerHandle(long interval) { TimerService timerService = context.getTimerService(); Timer timer = timerService.createTimer(interval, interval, null); return timer.getHandle(); } }
public class PnaScheduler implements Schedulable { public void perform(Date arg0, long arg1) { if(!started) { PnaScheduleFacadeLocal psLocal = EJBUtil.findLocalObject(PnaScheduleFacadeLocal.class); TimerHandle handle = psLocal.createTimerHandle(interval); System.out.println("Handle = " + handle); started = true; } } }
in your EJB createTimerHandle() you should ask the timerService for existing timers with getTimers().
If you only one (looks like, theres no info) you skip the creation if the Collection is not empty.