ejb3/src/main/java/org/jboss/as/ejb3/timerservice/TimerServiceImpl.java
public void restoreTimers(final List<ScheduleTimer> autoTimers) {
        // get the persisted timers which are considered active
        List<TimerImpl> restorableTimers = this.getActivePersistentTimers();

        //timers are removed from the list as they are loaded
        final List<ScheduleTimer> newAutoTimers = new LinkedList<ScheduleTimer>(autoTimers);

        if (EJB3_TIMER_LOGGER.isDebugEnabled()) {
            EJB3_TIMER_LOGGER.debug("Found " + restorableTimers.size() + " active persistentTimers for timedObjectId: "
                    + getInvoker().getTimedObjectId());
        }
        // now "start" each of the restorable timer. This involves, moving the timer to an ACTIVE state
        // and scheduling the timer task
        for (final TimerImpl activeTimer : restorableTimers) {

            if (activeTimer.isAutoTimer()) {
                CalendarTimer calendarTimer = (CalendarTimer) activeTimer;
                boolean found = false;
                //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(calendarTimer.getTimeoutMethod(), methodName, params)) {

                        //the timers have the same method.
                        //now lets make sure the schedule is the same
                        // and the timer does not change the persistence
                        if (this.doesScheduleMatch(calendarTimer.getScheduleExpression(), timer.getScheduleExpression()) && timer.getTimerConfig().isPersistent()) {
                            it.remove();
                            found = true;
                            break;
                        }
                    }
                }
                if (!found) {
                    activeTimer.setTimerState(TimerState.CANCELED, null);
                } else {
                    // ensure state switch to active if was TIMEOUT in the DB
                    // if the persistence is shared it must be ensured to not update
                    // timers of other nodes in the cluster
                    activeTimer.setTimerState(TimerState.ACTIVE, null);
                    calendarTimer.handleRestorationCalculation();
                }
                try {
                    this.persistTimer(activeTimer, false);
                } catch (Exception e) {
                    EJB3_TIMER_LOGGER.failedToPersistTimerOnStartup(activeTimer, e);
                }
                if (found) {
                    startTimer(activeTimer);
                    EJB3_TIMER_LOGGER.debugv("Started existing auto timer: {0}", activeTimer);
                }
            } else if (!ineligibleTimerStates.contains(activeTimer.getState())) {
                startTimer(activeTimer);
            }
            EJB3_TIMER_LOGGER.debugv("Started timer: {0}",  activeTimer);
        }

        for (ScheduleTimer timer : newAutoTimers) {
            this.loadAutoTimer(timer.getScheduleExpression(), timer.getTimerConfig(), timer.getMethod());
        }

    }
public void restoreTimers(final List<ScheduleTimer> autoTimers) {
        // get the persisted timers which are considered active
        List<TimerImpl> restorableTimers = this.getActivePersistentTimers();

        //timers are removed from the list as they are loaded
        final List<ScheduleTimer> newAutoTimers = new LinkedList<ScheduleTimer>(autoTimers);

        if (EJB3_TIMER_LOGGER.isDebugEnabled()) {
            EJB3_TIMER_LOGGER.debug("Found " + restorableTimers.size() + " active persistentTimers for timedObjectId: "
                    + getInvoker().getTimedObjectId());
        }
        // now "start" each of the restorable timer. This involves, moving the timer to an ACTIVE state
        // and scheduling the timer task
        for (final TimerImpl activeTimer : restorableTimers) {

            if (activeTimer.isAutoTimer()) {
                CalendarTimer calendarTimer = (CalendarTimer) activeTimer;
                boolean found = false;
                //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(calendarTimer.getTimeoutMethod(), methodName, params)) {

                        //the timers have the same method.
                        //now lets make sure the schedule is the same
                        // and the timer does not change the persistence
                        if (this.doesScheduleMatch(calendarTimer.getScheduleExpression(), timer.getScheduleExpression()) && timer.getTimerConfig().isPersistent()) {
                            it.remove();
                            found = true;
                            break;
                        }
                    }
                }
                if (!found) {
                    activeTimer.setTimerState(TimerState.CANCELED, null);
                } else {
                    // ensure state switch to active if was TIMEOUT in the DB
                    // if the persistence is shared it must be ensured to not update
                    // timers of other nodes in the cluster
                    activeTimer.setTimerState(TimerState.ACTIVE, null);
                    calendarTimer.handleRestorationCalculation();
                }
                try {
                    this.persistTimer(activeTimer, false);
                } catch (Exception e) {
                    EJB3_TIMER_LOGGER.failedToPersistTimerOnStartup(activeTimer, e);
                }
                if (found) {
                    startTimer(activeTimer);
                    EJB3_TIMER_LOGGER.debugv("Started existing auto timer: {0}", activeTimer);
                }
            } else if (!ineligibleTimerStates.contains(activeTimer.getState())) {
                startTimer(activeTimer);
            }
            EJB3_TIMER_LOGGER.debugv("Started timer: {0}",  activeTimer);
        }

        for (ScheduleTimer timer : newAutoTimers) {
            this.loadAutoTimer(timer.getScheduleExpression(), timer.getTimerConfig(), timer.getMethod());
        }

    }
public void restoreTimers ( final List < ScheduleTimer > autoTimers ) { // get the persisted timers which are considered active List < TimerImpl > restorableTimers = this . getActivePersistentTimers ( ) ; //timers are removed from the list as they are loaded final List < ScheduleTimer > newAutoTimers = new LinkedList < ScheduleTimer > ( autoTimers ) ; if ( EJB3_TIMER_LOGGER . isDebugEnabled ( ) ) { EJB3_TIMER_LOGGER . debug ( "Found " + restorableTimers . size ( ) + " active persistentTimers for timedObjectId: " + getInvoker ( ) . getTimedObjectId ( ) ) ; } // now "start" each of the restorable timer. This involves, moving the timer to an ACTIVE state // and scheduling the timer task for ( final TimerImpl activeTimer : restorableTimers ) { if ( activeTimer . isAutoTimer ( ) ) { CalendarTimer calendarTimer = ( CalendarTimer ) activeTimer ; boolean found = false ; //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 ( calendarTimer . getTimeoutMethod ( ) , methodName , params ) ) { //the timers have the same method. //now lets make sure the schedule is the same // and the timer does not change the persistence if ( this . doesScheduleMatch ( calendarTimer . getScheduleExpression ( ) , timer . getScheduleExpression ( ) ) && timer . getTimerConfig ( ) . isPersistent ( ) ) { it . remove ( ) ; found = true ; break ; } } } if ( ! found ) { activeTimer . setTimerState ( TimerState . CANCELED , null ) ; } else { // ensure state switch to active if was TIMEOUT in the DB // if the persistence is shared it must be ensured to not update // timers of other nodes in the cluster activeTimer . setTimerState ( TimerState . ACTIVE , null ) ; calendarTimer . handleRestorationCalculation ( ) ; } try { this . persistTimer ( activeTimer , false ) ; } catch ( Exception e ) { EJB3_TIMER_LOGGER . failedToPersistTimerOnStartup ( activeTimer , e ) ; } if ( found ) { startTimer ( activeTimer ) ; EJB3_TIMER_LOGGER . debugv ( "Started existing auto timer: {0}" , activeTimer ) ; } } else if ( ! ineligibleTimerStates . contains ( activeTimer . getState ( ) ) ) { startTimer ( activeTimer ) ; } EJB3_TIMER_LOGGER . debugv ( "Started timer: {0}" , activeTimer ) ; } for ( ScheduleTimer timer : newAutoTimers ) { this . loadAutoTimer ( timer . getScheduleExpression ( ) , timer . getTimerConfig ( ) , timer . getMethod ( ) ) ; } }
Restores persisted timers, corresponding to this timerservice, which are eligible for any new timeouts.
<p>
This includes timers whose {@link TimerState} is <b>neither</b> of the following:
<ul>
<li>{@link TimerState#CANCELED}</li>
<li>{@link TimerState#EXPIRED}</li>
</ul>
</p>
<p>
All such restored timers will be schedule for their next timeouts.
</p>

@param autoTimers
Restores persisted timers corresponding to this timerservice which are eligible for any new timeouts . <p > This includes timers whose { @link TimerState } is <b > neither< / b > of the following : <ul > <li > { @link TimerState#CANCELED } < / li > <li > { @link TimerState#EXPIRED } < / li > < / ul > < / p > <p > All such restored timers will be schedule for their next timeouts . < / p >