1 22 package org.jboss.ejb3.test.timerdependency; 23 24 import javax.ejb.EJB ; 25 26 import org.jboss.annotation.ejb.Management; 27 import org.jboss.annotation.ejb.Service; 28 import org.jboss.annotation.ejb.Depends; 29 import org.jboss.logging.Logger; 30 31 35 @Service (objectName="telcordia.smg:service=InitTimer") 36 @Management(InitTimerMBean.class) 37 @Depends(value="jboss.j2ee:jar=timerdependency.jar,name=TimerTestBean,service=EJB3") 38 public class InitTimer implements InitTimerMBean 39 { 40 private static final Logger log = Logger.getLogger(InitTimer.class); 41 42 @EJB 43 TimerTest timer; 44 45 private long intervalDuration_ = 1; 46 47 public void start() 48 { 49 log.info("called start"); 50 startTimer(); 51 } 52 53 public void create() 54 { 55 log.info("called create"); 56 } 57 58 public void stop() 59 { 60 log.info("called stop"); 61 } 62 63 public void destroy() 64 { 65 66 } 67 68 public long getInterval() { 69 return intervalDuration_; 71 } 72 73 public void setInterval(long interval) { 74 intervalDuration_ = interval; 76 } 78 79 void startTimer() 80 { 81 try { 82 log.info("Creating a timer with an interval duration of " + 83 intervalDuration_ + " ms."); 84 log.info("is timer valid: " + timer); 85 timer.createTimer(intervalDuration_); 86 } catch (Exception ex) { 87 log.error("Caught an unexpected exception."); 88 ex.printStackTrace(); 89 } 90 } 91 92 } 93 | Popular Tags |