01: package hero.util;
02:
03: import java.io.Serializable;
04:
05: import hero.util.HeroException;
06: import javax.ejb.Timer;
07:
08: public class TimerData implements Serializable {
09:
10: protected String _type;
11: protected long _ms;
12:
13: public TimerData(String type, long ms) {
14: _type = type;
15: _ms = ms;
16: }
17:
18: public String getType() {
19: return _type;
20: }
21:
22: public long getMs() {
23: return _ms;
24: }
25:
26: protected void setType(String type) {
27: _type = type;
28: }
29:
30: protected void setMs(long ms) {
31: _ms = ms;
32: }
33:
34: public void onStart(Timer t) throws HeroException {
35: // not used at now
36: System.out.println("----------> TimerData: starting Timer "
37: + getType() + " date = " + getMs());
38: }
39:
40: public void onStop(Timer t) throws HeroException {
41: //System.out.println("----------> TimerData: Stopping timer " + getType());
42: try {
43: t.cancel();
44: } catch (Exception e) {
45: throw new HeroException(e.getMessage());
46: }
47: }
48:
49: public void onTimeout(Timer t) throws HeroException {
50: // not used at now.
51: System.out.println("----------> TimerData: Timer " + getType()
52: + " timed out !!!!!! ");
53: }
54: }
|