KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > examples > ejb > timer > TestTimerBean


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6 package org.jfox.examples.ejb.timer;
7
8 import javax.ejb.CreateException JavaDoc;
9 import javax.ejb.EJBException JavaDoc;
10 import javax.ejb.SessionBean JavaDoc;
11 import javax.ejb.SessionContext JavaDoc;
12 import javax.ejb.TimedObject JavaDoc;
13 import javax.ejb.Timer JavaDoc;
14 import javax.ejb.TimerHandle JavaDoc;
15 import javax.ejb.TimerService JavaDoc;
16
17 /**
18  * @author <a HREF="mailto:yy.young@gmail.com">Young Yang</a>
19  */

20
21 public class TestTimerBean implements SessionBean JavaDoc, TimedObject JavaDoc {
22     private SessionContext JavaDoc context;
23
24     public TestTimerBean() {
25     }
26
27     public void setSessionContext(SessionContext JavaDoc sessionContext) throws EJBException JavaDoc {
28         context = sessionContext;
29     }
30
31     public void ejbRemove() throws EJBException JavaDoc {
32     }
33
34     public void ejbActivate() throws EJBException JavaDoc {
35     }
36
37     public void ejbPassivate() throws EJBException JavaDoc {
38     }
39
40     public void ejbCreate() throws CreateException JavaDoc {
41     }
42
43     public void ejbTimeout(Timer JavaDoc timer) {
44         System.out.println("ejbTimeout, Timer is: " + timer);
45
46         TimerHandle JavaDoc handle = timer.getHandle();
47         System.out.println("TimerHandler: " + handle);
48
49         System.out.println("Timer get by TimerHandler: " + handle.getTimer());
50     }
51
52     public void shedule(long time) {
53         TimerService JavaDoc timerService = context.getTimerService();
54         timerService.createTimer(time, null);
55     }
56 }
57
Popular Tags