Привет. Может ли TimerService.getTimers() вернуть таймеры, созданные другими бинами?
| Код | @Resource private TimerService timerService;
@SuppressWarnings("unchecked") public void unschedulePurge() { int count = 0; for (Timer t : (Collection<Timer>)timerService.getTimers()) { count++; if (DDA_PURGE_TIMER.equals(t.getInfo())) { // нужна ли эта проверка? t.cancel(); } } if (count > 0) log.debug("unschedulePurge(): stopped timers: " + count); }
public void schedulePurge() throws Exception { unschedulePurge(); Properties props = loadProperties(); long purgePeriod = getPurgePeriod(props); if (purgePeriod == 0) { log.debug("schedulePurge(): dda.purge.period empty, not scheduled"); } else { timerService.createTimer(30*1000, purgePeriod, DDA_PURGE_TIMER); log.debug("schedulePurge(): started timer with period: " + purgePeriod); } }
|
|