1 Reply Latest reply on Aug 28, 2006 11:05 AM by Wolf-Dieter Fink

    TimedObject question.

    Clarindo Schroeder Newbie


      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();

      and another class to start the service:
      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;

      The schedule does it fine, but every time I restart my JBoss it will create
      another Timer, and JBoss will also restart old Timers that are serialized, I need to check in code if there is already a Timer that restarts the service and create another one only if necessary.

      Thanks for any help/directions.