Search in sources :

Example 1 with ScheduleInfo

use of org.apache.openejb.assembler.classic.ScheduleInfo in project tomee by apache.

the class EjbJarInfoBuilder method copySchedules.

private void copySchedules(final List<Timer> timers, final List<MethodScheduleInfo> scheduleInfos) {
    final Map<NamedMethod, MethodScheduleInfo> methodScheduleInfoMap = new HashMap<>();
    for (final Timer timer : timers) {
        final NamedMethod timeoutMethod = timer.getTimeoutMethod();
        MethodScheduleInfo methodScheduleInfo = methodScheduleInfoMap.get(timer.getTimeoutMethod());
        if (methodScheduleInfo == null) {
            methodScheduleInfo = new MethodScheduleInfo();
            methodScheduleInfoMap.put(timeoutMethod, methodScheduleInfo);
            methodScheduleInfo.method = toInfo(timeoutMethod);
        }
        final ScheduleInfo scheduleInfo = new ScheduleInfo();
        //Copy TimerSchedule
        final TimerSchedule timerSchedule = timer.getSchedule();
        if (timerSchedule != null) {
            scheduleInfo.second = timerSchedule.getSecond();
            scheduleInfo.minute = timerSchedule.getMinute();
            scheduleInfo.hour = timerSchedule.getHour();
            scheduleInfo.dayOfWeek = timerSchedule.getDayOfWeek();
            scheduleInfo.dayOfMonth = timerSchedule.getDayOfMonth();
            scheduleInfo.month = timerSchedule.getMonth();
            scheduleInfo.year = timerSchedule.getYear();
        }
        //Copy other attributes
        scheduleInfo.timezone = timer.getTimezone();
        if (timer.getStart() != null) {
            scheduleInfo.start = timer.getStart().toGregorianCalendar().getTime();
        }
        if (timer.getEnd() != null) {
            scheduleInfo.end = timer.getEnd().toGregorianCalendar().getTime();
        }
        scheduleInfo.info = timer.getInfo();
        if (timer.getPersistent() != null) {
            scheduleInfo.persistent = timer.getPersistent();
        }
        methodScheduleInfo.schedules.add(scheduleInfo);
    }
    scheduleInfos.addAll(methodScheduleInfoMap.values());
}
Also used : MethodScheduleInfo(org.apache.openejb.assembler.classic.MethodScheduleInfo) TimerSchedule(org.apache.openejb.jee.TimerSchedule) Timer(org.apache.openejb.jee.Timer) HashMap(java.util.HashMap) NamedMethod(org.apache.openejb.jee.NamedMethod) MethodScheduleInfo(org.apache.openejb.assembler.classic.MethodScheduleInfo) ScheduleInfo(org.apache.openejb.assembler.classic.ScheduleInfo)

Aggregations

HashMap (java.util.HashMap)1 MethodScheduleInfo (org.apache.openejb.assembler.classic.MethodScheduleInfo)1 ScheduleInfo (org.apache.openejb.assembler.classic.ScheduleInfo)1 NamedMethod (org.apache.openejb.jee.NamedMethod)1 Timer (org.apache.openejb.jee.Timer)1 TimerSchedule (org.apache.openejb.jee.TimerSchedule)1