Search in sources :

Example 1 with AutoTimer

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);
        }
    }
}
Also used : AutoTimer(org.jboss.as.ejb3.timerservice.AutoTimer) List(java.util.List) Method(java.lang.reflect.Method) Map(java.util.Map)

Example 2 with AutoTimer

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);
            }
        }
    }
}
Also used : AutoTimer(org.jboss.as.ejb3.timerservice.AutoTimer) ScheduleExpression(javax.ejb.ScheduleExpression) TimerMetaData(org.jboss.metadata.ejb.spec.TimerMetaData) IScheduleTarget(org.jboss.metadata.common.ejb.IScheduleTarget) ScheduleMetaData(org.jboss.metadata.ejb.spec.ScheduleMetaData)

Example 3 with 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);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Method(java.lang.reflect.Method) Map(java.util.Map) HashMap(java.util.HashMap) ScheduleTimer(org.jboss.as.ejb3.timerservice.spi.ScheduleTimer)

Aggregations

Method (java.lang.reflect.Method)2 List (java.util.List)2 Map (java.util.Map)2 AutoTimer (org.jboss.as.ejb3.timerservice.AutoTimer)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 ScheduleExpression (javax.ejb.ScheduleExpression)1 ScheduleTimer (org.jboss.as.ejb3.timerservice.spi.ScheduleTimer)1 IScheduleTarget (org.jboss.metadata.common.ejb.IScheduleTarget)1 ScheduleMetaData (org.jboss.metadata.ejb.spec.ScheduleMetaData)1 TimerMetaData (org.jboss.metadata.ejb.spec.TimerMetaData)1