KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > EjbTimerUtil


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.ejb3;
8
9 import javax.ejb.TimerService JavaDoc;
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 /**
17  * Comment
18  *
19  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
20  * @version $Revision: 1.3.2.2 $
21  */

22 public class EjbTimerUtil
23 {
24    private static final Logger log = Logger.getLogger(EjbTimerUtil.class);
25
26    public static TimerService JavaDoc getTimerService(Container container, TimedObjectInvoker invoker)
27    {
28       TimerService JavaDoc 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 JavaDoc e)
35       {
36          //throw new EJBException("Could not create timer service", e);
37
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 JavaDoc e)
57       {
58          //throw new EJBException("Could not remove timer service", e);
59
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