use of org.jboss.as.ejb3.timerservice.AutoTimer in project wildfly by wildfly.
the class TimerMethodMergingProcessor method handleAnnotations.
@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
final RuntimeAnnotationInformation<AutoTimer> scheduleAnnotationData = MethodAnnotationAggregator.runtimeAnnotationInformation(componentClass, applicationClasses, deploymentReflectionIndex, Schedule.class);
final Set<Method> timerAnnotationData = MethodAnnotationAggregator.runtimeAnnotationPresent(componentClass, applicationClasses, deploymentReflectionIndex, Timeout.class);
final Method timeoutMethod;
if (timerAnnotationData.size() > 1) {
throw EjbLogger.ROOT_LOGGER.componentClassHasMultipleTimeoutAnnotations(componentClass);
} else if (timerAnnotationData.size() == 1) {
timeoutMethod = timerAnnotationData.iterator().next();
} else {
timeoutMethod = null;
}
description.setTimeoutMethod(timeoutMethod);
//now for the schedule methods
for (Map.Entry<Method, List<AutoTimer>> entry : scheduleAnnotationData.getMethodAnnotations().entrySet()) {
for (AutoTimer timer : entry.getValue()) {
description.addScheduleMethod(entry.getKey(), timer);
}
}
}
use of org.jboss.as.ejb3.timerservice.AutoTimer in project wildfly by wildfly.
the class TimerMethodMergingProcessor method parseScheduleMethods.
private void parseScheduleMethods(final EnterpriseBeanMetaData beanMetaData, final EJBComponentDescription sessionBean, final Class<?> componentClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException {
if (beanMetaData instanceof IScheduleTarget) {
IScheduleTarget md = (IScheduleTarget) beanMetaData;
if (md.getTimers() != null) {
for (final TimerMetaData timer : md.getTimers()) {
AutoTimer autoTimer = new AutoTimer();
autoTimer.getTimerConfig().setInfo(timer.getInfo());
autoTimer.getTimerConfig().setPersistent(timer.isPersistent());
final ScheduleExpression scheduleExpression = autoTimer.getScheduleExpression();
final ScheduleMetaData schedule = timer.getSchedule();
if (schedule != null) {
scheduleExpression.dayOfMonth(schedule.getDayOfMonth());
scheduleExpression.dayOfWeek(schedule.getDayOfWeek());
scheduleExpression.hour(schedule.getHour());
scheduleExpression.minute(schedule.getMinute());
scheduleExpression.month(schedule.getMonth());
scheduleExpression.second(schedule.getSecond());
scheduleExpression.year(schedule.getYear());
}
if (timer.getEnd() != null) {
scheduleExpression.end(timer.getEnd().getTime());
}
if (timer.getStart() != null) {
scheduleExpression.start(timer.getStart().getTime());
}
scheduleExpression.timezone(timer.getTimezone());
sessionBean.addScheduleMethod(MethodResolutionUtils.resolveMethod(timer.getTimeoutMethod(), componentClass, deploymentReflectionIndex), autoTimer);
}
}
}
}
use of org.jboss.as.ejb3.timerservice.AutoTimer in project wildfly by wildfly.
the class TimerServiceImpl method activate.
public synchronized void activate() {
final List<ScheduleTimer> timers = new ArrayList<ScheduleTimer>();
for (Map.Entry<Method, List<AutoTimer>> entry : autoTimers.entrySet()) {
for (AutoTimer timer : entry.getValue()) {
timers.add(new ScheduleTimer(entry.getKey(), timer.getScheduleExpression(), timer.getTimerConfig()));
}
}
// restore the timers
restoreTimers(timers);
}
Aggregations