1 16 17 package org.springframework.scheduling.commonj; 18 19 import commonj.timers.TimerListener; 20 21 41 public class ScheduledTimerListener { 42 43 private TimerListener timerListener; 44 45 private long delay = 0; 46 47 private long period = -1; 48 49 private boolean fixedRate = false; 50 51 52 60 public ScheduledTimerListener() { 61 } 62 63 68 public ScheduledTimerListener(TimerListener timerListener) { 69 this.timerListener = timerListener; 70 } 71 72 78 public ScheduledTimerListener(TimerListener timerListener, long delay) { 79 this.timerListener = timerListener; 80 this.delay = delay; 81 } 82 83 90 public ScheduledTimerListener(TimerListener timerListener, long delay, long period, boolean fixedRate) { 91 this.timerListener = timerListener; 92 this.delay = delay; 93 this.period = period; 94 this.fixedRate = fixedRate; 95 } 96 97 102 public ScheduledTimerListener(Runnable timerTask) { 103 setRunnable(timerTask); 104 } 105 106 112 public ScheduledTimerListener(Runnable timerTask, long delay) { 113 setRunnable(timerTask); 114 this.delay = delay; 115 } 116 117 124 public ScheduledTimerListener(Runnable timerTask, long delay, long period, boolean fixedRate) { 125 setRunnable(timerTask); 126 this.delay = delay; 127 this.period = period; 128 this.fixedRate = fixedRate; 129 } 130 131 132 136 public void setRunnable(Runnable timerTask) { 137 this.timerListener = new DelegatingTimerListener(timerTask); 138 } 139 140 143 public void setTimerListener(TimerListener timerListener) { 144 this.timerListener = timerListener; 145 } 146 147 150 public TimerListener getTimerListener() { 151 return this.timerListener; 152 } 153 154 161 public void setDelay(long delay) { 162 this.delay = delay; 163 } 164 165 168 public long getDelay() { 169 return this.delay; 170 } 171 172 187 public void setPeriod(long period) { 188 this.period = period; 189 } 190 191 194 public long getPeriod() { 195 return this.period; 196 } 197 198 203 public boolean isOneTimeTask() { 204 return (this.period < 0); 205 } 206 207 214 public void setFixedRate(boolean fixedRate) { 215 this.fixedRate = fixedRate; 216 } 217 218 221 public boolean isFixedRate() { 222 return this.fixedRate; 223 } 224 225 } 226 | Popular Tags |