1 7 package org.jboss.ejb3; 8 9 import javax.ejb.TimerService ; 10 import org.jboss.ejb.txtimer.EJBTimerService; 11 import org.jboss.ejb.txtimer.TimedObjectInvoker; 12 import org.jboss.logging.Logger; 13 import org.jboss.mx.util.MBeanProxy; 14 import org.jboss.mx.util.MBeanServerLocator; 15 16 22 public class EjbTimerUtil 23 { 24 private static final Logger log = Logger.getLogger(EjbTimerUtil.class); 25 26 public static TimerService getTimerService(Container container, TimedObjectInvoker invoker) 27 { 28 TimerService timerService = null; 29 try 30 { 31 EJBTimerService service = (EJBTimerService) MBeanProxy.get(EJBTimerService.class, EJBTimerService.OBJECT_NAME, MBeanServerLocator.locateJBoss()); 32 timerService = service.createTimerService(container.getObjectName(), null, invoker); 33 } 34 catch (Exception e) 35 { 36 if (log.isTraceEnabled()) 38 { 39 log.error("Unable to initialize timer service", e); 40 } 41 else 42 { 43 log.error("Unable to initialize timer service"); 44 } 45 } 46 return timerService; 47 } 48 49 public static void removeTimerService(Container container) 50 { 51 try 52 { 53 EJBTimerService service = (EJBTimerService) MBeanProxy.get(EJBTimerService.class, EJBTimerService.OBJECT_NAME, MBeanServerLocator.locateJBoss()); 54 service.removeTimerService(container.getObjectName(), null); 55 } 56 catch (Exception e) 57 { 58 if (log.isTraceEnabled()) 60 { 61 log.error("Unable to initialize timer service", e); 62 } 63 else 64 { 65 log.error("Unable to initialize timer service"); 66 } 67 } 68 } 69 } 70 | Popular Tags |