01: package com.bm.utils.substitues;
02:
03: import java.io.Serializable;
04: import java.util.Date;
05:
06: import javax.ejb.EJBException;
07: import javax.ejb.NoSuchObjectLocalException;
08: import javax.ejb.Timer;
09: import javax.ejb.TimerHandle;
10:
11: /**
12: * Author: Marcus Nilsson Date: May 16, 2007 Time: 9:52:08 AM
13: */
14: public class TimerMock extends Thread implements Timer {
15: private long timeout;
16:
17: private Serializable info;
18:
19: /**
20: * Constructor.
21: *
22: * @param timeout
23: * timeout
24: * @param info
25: * the info object.
26: */
27: public TimerMock(long timeout, Serializable info) {
28: this .timeout = timeout;
29: this .info = info;
30: }
31:
32: /**
33: * {@inheritDoc}
34: */
35: public void run() {
36: try {
37: Thread.sleep(this .timeout);
38: } catch (InterruptedException e) {
39: e.printStackTrace();
40: }
41:
42: this .timerExpired();
43: }
44:
45: /**
46: * {@inheritDoc}
47: */
48: public void timerExpired() {
49: }
50:
51: /**
52: * {@inheritDoc}
53: */
54: public void cancel() throws IllegalStateException,
55: NoSuchObjectLocalException, EJBException {
56: this .interrupt();
57: }
58:
59: /**
60: * {@inheritDoc}
61: */
62: public long getTimeRemaining() throws IllegalStateException,
63: NoSuchObjectLocalException, EJBException {
64: return this .timeout;
65: }
66:
67: /**
68: * {@inheritDoc}
69: */
70: public Date getNextTimeout() throws IllegalStateException,
71: NoSuchObjectLocalException, EJBException {
72: return null;
73: }
74:
75: /**
76: * {@inheritDoc}
77: */
78: public Serializable getInfo() throws IllegalStateException,
79: NoSuchObjectLocalException, EJBException {
80: return info;
81: }
82:
83: /**
84: * {@inheritDoc}
85: */
86: public TimerHandle getHandle() throws IllegalStateException,
87: NoSuchObjectLocalException, EJBException {
88: return null;
89: }
90: }
|