List<Timer> timers = timerConsumer.getTimer();
// TODO : The NamedMethod object implements equals and hashCode, so we could rely on that rather than collecting strings
Set<String> methodsConfiguredInDeploymentXml = new HashSet<String>();
for (Timer timer : timers) {
NamedMethod namedMethod = timer.getTimeoutMethod();
methodsConfiguredInDeploymentXml.add(namedMethod.getMethodName() + (namedMethod.getMethodParams() == null ? "" : Join.join("", namedMethod.getMethodParams().getMethodParam())));
}
for (Annotated<Method> method : scheduleMethods) {
// Don't add the schedules from annotations if the schedules have been
// supplied for this method via xml. The xml is considered an override.
if (methodsConfiguredInDeploymentXml.contains(method.get().getName() + Join.join("", (Object[]) asStrings(method.get().getParameterTypes())))) {
continue;
}
List<javax.ejb.Schedule> scheduleAnnotationList = new ArrayList<javax.ejb.Schedule>();
javax.ejb.Schedules schedulesAnnotation = method.getAnnotation(javax.ejb.Schedules.class);
if (schedulesAnnotation != null) {
scheduleAnnotationList.addAll(asList(schedulesAnnotation.value()));
}
javax.ejb.Schedule scheduleAnnotation = method.getAnnotation(javax.ejb.Schedule.class);
if (scheduleAnnotation != null) {
scheduleAnnotationList.add(scheduleAnnotation);
}
for (javax.ejb.Schedule schedule : scheduleAnnotationList) {
Timer timer = new Timer();
timer.setPersistent(schedule.persistent());
timer.setInfo((schedule.info() == null || schedule.info().isEmpty()) ? null : schedule.info());
timer.setTimezone((schedule.timezone() == null || schedule.timezone().isEmpty()) ? null : schedule.timezone());
//Copy TimerSchedule
TimerSchedule timerSchedule = new TimerSchedule();
timerSchedule.setSecond(schedule.second());
timerSchedule.setMinute(schedule.minute());
timerSchedule.setHour(schedule.hour());
timerSchedule.setDayOfWeek(schedule.dayOfWeek());
timerSchedule.setDayOfMonth(schedule.dayOfMonth());
timerSchedule.setMonth(schedule.month());
timerSchedule.setYear(schedule.year());
timer.setSchedule(timerSchedule);
//Copy Method Signature
timer.setTimeoutMethod(new NamedMethod(method.get()));
timers.add(timer);
}
}
}