boolean found = false;
final CalendarTimerEntity entity = (CalendarTimerEntity) activeTimer.getPersistentState();
//so we know we have an auto timer. We need to try and match it up with the auto timers.
ListIterator<ScheduleTimer> it = newAutoTimers.listIterator();
while (it.hasNext()) {
ScheduleTimer timer = it.next();
final String methodName = timer.getMethod().getName();
final String[] params = new String[timer.getMethod().getParameterTypes().length];
for (int i = 0; i < timer.getMethod().getParameterTypes().length; ++i) {
params[i] = timer.getMethod().getParameterTypes()[i].getName();
}
if (doesTimeoutMethodMatch(entity.getTimeoutMethod(), methodName, params)) {
//the timers have the same method.
//now lets make sure the schedule is the same
if (this.doesScheduleMatch(entity.getScheduleExpression(), timer.getScheduleExpression())) {
it.remove();
found = true;
break;
}
}
}
if (found) {
startTimer(activeTimer);
logger.debug("Started timer: " + activeTimer);
// save any changes to the state (that will have happened on call to startTimer)
this.persistTimer(activeTimer);
} else {
//the annotation is no longer there
this.removeTimer(activeTimer);
}
}
//TODO: we need to make sure that these only fire one event after being restored
this.startTimer(activeTimer);
logger.debug("Started timer: " + activeTimer);
// save any changes to the state (that will have happened on call to startTimer)
this.persistTimer(activeTimer);
}
for (ScheduleTimer timer : newAutoTimers) {
this.loadAutoTimer(timer.getScheduleExpression(), timer.getTimerConfig(), timer.getMethod());
}
}