Timers appear to be persistent in glassfish so now canceling any old
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 24 Mar 2008 11:18:53 +0000 (11:18 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 24 Mar 2008 11:18:53 +0000 (11:18 +0000)
itmers before starting the new one.

trunk/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java

index 048e94b55041575f0815b12a699b01758d49ad1b..fffd74b892b206f734f9bbfc019d9926e77501e3 100644 (file)
@@ -16,6 +16,8 @@
 
 package org.wamblee.timer;
 
+import java.util.Collection;
+
 import javax.annotation.Resource;
 import javax.ejb.MessageDriven;
 import javax.ejb.Timeout;
@@ -59,6 +61,10 @@ public class TimerBean implements MessageListener {
         try {
             int interval = (Integer)msg.getObject();
             LOG.info("Initializing timer with interval " + interval + " seconds");
+            for (Timer timer: (Collection<Timer>)_timerService.getTimers()) { 
+               LOG.info("Canceling old timers: " + timer);
+               timer.cancel();
+            }
             _timerService.createTimer(1000, interval*1000, null);
         } catch (JMSException e) {
             throw new RuntimeException(e.getMessage());