KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ejb > timer > EJBTimerHandler


1 package org.jfox.ejb.timer;
2
3 import javax.ejb.EJBException JavaDoc;
4 import javax.ejb.NoSuchObjectLocalException JavaDoc;
5 import javax.ejb.Timer JavaDoc;
6 import javax.ejb.TimerHandle JavaDoc;
7
8 import org.jfox.ejb.connector.EJBContainerImpl;
9 import org.jfox.ioc.ComponentName;
10 import org.jfox.ioc.Registry;
11 import org.jfox.ioc.connector.Container;
12
13 /**
14  * @author <a HREF="mailto:yy.young@gmail.com">Young Yang</a>
15  */

16
17 public class EJBTimerHandler implements TimerHandle JavaDoc {
18     private String JavaDoc ejbName;
19     private String JavaDoc identity;
20
21     public EJBTimerHandler(String JavaDoc ejbName, String JavaDoc identity) {
22         this.ejbName = ejbName;
23         this.identity = identity;
24     }
25
26     /**
27      * @return
28      * @throws IllegalStateException
29      * @throws NoSuchObjectLocalException
30      * @throws EJBException
31      */

32     public Timer JavaDoc getTimer() throws IllegalStateException JavaDoc, NoSuchObjectLocalException JavaDoc, EJBException JavaDoc {
33         try {
34         EJBTimerService timerService = (EJBTimerService) ((EJBContainerImpl) Registry.getInstance().getComponentInstance(ComponentName.parseString(Container.class.getName() + "@EJB"))).getBucket(ejbName).getTimerService();
35         return timerService.getTimer(identity);
36         }
37         catch(Exception JavaDoc e){
38             e.printStackTrace();
39             return null;
40         }
41     }
42
43
44     public String JavaDoc toString() {
45         return "EJBTimerHandler{" +
46                 "ejbName='" + ejbName + "'" +
47                 ", identity='" + identity + "'" +
48                 "}";
49     }
50
51     public static void main(String JavaDoc[] args) {
52
53     }
54 }
55
56
Popular Tags