1 43 package org.objectweb.jotm; 44 45 public class TimerEvent { 46 47 private TimerEventListener listener = null; 48 private Object arg = null; 49 private long reminding = 0; 50 private long startvalue; 51 private boolean permanent = false; 52 private boolean stopped = false; 53 54 61 public TimerEvent(TimerEventListener l, long timeout, Object a, boolean p) { 62 if (TraceTm.jta.isDebugEnabled()) { 63 TraceTm.jta.debug("TimerEvent.new("+l+","+timeout+","+a+","+p+")"); 64 } 65 66 listener = l; 67 reminding = timeout; 68 startvalue = timeout; 69 arg = a; 70 permanent = p; 71 } 72 73 74 78 public long update() { 79 return --reminding; 80 } 81 82 85 public void restart() { 86 if (TraceTm.jta.isDebugEnabled()) { 87 TraceTm.jta.debug("TimerEvent.new("+listener+").restart"); 88 } 89 90 stopped = false; 91 reminding = startvalue; 92 } 93 94 97 public void process() { 98 if (listener != null) { 99 if (TraceTm.jta.isDebugEnabled()) { 100 TraceTm.jta.debug("TimerEvent.new("+listener+".process"); 101 } 102 103 listener.timeoutExpired(arg); 104 } 105 } 106 107 public void change(long timeout, Object a) { 108 if (TraceTm.jta.isDebugEnabled()) { 109 TraceTm.jta.debug("TimerEvent("+listener+").change("+timeout+","+a+")"); 110 } 111 112 stopped = false; 113 startvalue = timeout; 114 reminding = startvalue; 115 arg = a; 116 } 117 118 121 public void unset() { 122 if (TraceTm.jta.isDebugEnabled()) { 123 TraceTm.jta.debug("TimerEvent("+listener+").unset"); 124 } 125 126 reminding = 1; 128 arg = null; 129 listener = null; 130 permanent = false; 131 stopped = false; 132 } 133 134 137 public void stop() { 138 if (TraceTm.jta.isDebugEnabled()) { 139 TraceTm.jta.debug("TimerEvent("+listener+").stop"); 140 } 141 142 reminding = 1000000; 144 stopped = true; 145 } 146 147 150 public boolean valid() { 151 return (listener != null); 152 } 153 154 157 public boolean ispermanent() { 158 return permanent; 159 } 160 161 164 public boolean isStopped() { 165 return stopped; 166 } 167 } 168 169 | Popular Tags |