ejb3/src/main/java/org/jboss/as/ejb3/timerservice/TimerServiceImpl.java
protected void scheduleTimeout(TimerImpl timer, boolean newTimer) {
        synchronized (scheduledTimerFutures) {
            if (!newTimer && !scheduledTimerFutures.containsKey(timer.getId())) {
                //this timer has been cancelled by another thread. We just return
                return;
            }

            Date nextExpiration = timer.getNextExpiration();
            if (nextExpiration == null) {
                EJB3_TIMER_LOGGER.nextExpirationIsNull(timer);
                return;
            }
            // create the timer task
            final TimerTask<?> timerTask = timer.getTimerTask();
            // find out how long is it away from now
            long delay = nextExpiration.getTime() - System.currentTimeMillis();
            // if in past, then trigger immediately
            if (delay < 0) {
                delay = 0;
            }
            long intervalDuration = timer.getInterval();
            final Task task = new Task(timerTask, ejbComponentInjectedValue.getValue().getControlPoint());
            if (intervalDuration > 0) {
                EJB3_TIMER_LOGGER.debugv("Scheduling timer {0} at fixed rate, starting at {1} milliseconds from now with repeated interval={2}",
                        timer, delay, intervalDuration);
                // schedule the task
                this.timerInjectedValue.getValue().scheduleAtFixedRate(task, delay, intervalDuration);
                // maintain it in timerservice for future use (like cancellation)
                this.scheduledTimerFutures.put(timer.getId(), task);
            } else {
                EJB3_TIMER_LOGGER.debugv("Scheduling a single action timer {0} starting at {1} milliseconds from now", timer, delay);
                // schedule the task
                this.timerInjectedValue.getValue().schedule(task, delay);
                // maintain it in timerservice for future use (like cancellation)
                this.scheduledTimerFutures.put(timer.getId(), task);

            }
        }
    }
protected void scheduleTimeout(TimerImpl timer, boolean newTimer) {
        synchronized (scheduledTimerFutures) {
            if (!newTimer && !scheduledTimerFutures.containsKey(timer.getId())) {
                //this timer has been cancelled by another thread. We just return
                return;
            }

            Date nextExpiration = timer.getNextExpiration();
            if (nextExpiration == null) {
                EJB3_TIMER_LOGGER.nextExpirationIsNull(timer);
                return;
            }
            // create the timer task
            final TimerTask<?> timerTask = timer.getTimerTask();
            // find out how long is it away from now
            long delay = nextExpiration.getTime() - System.currentTimeMillis();
            // if in past, then trigger immediately
            if (delay < 0) {
                delay = 0;
            }
            long intervalDuration = timer.getInterval();
            final Task task = new Task(timerTask, ejbComponentInjectedValue.getValue().getControlPoint());
            if (intervalDuration > 0) {
                EJB3_TIMER_LOGGER.debugv("Scheduling timer {0} at fixed rate, starting at {1} milliseconds from now with repeated interval={2}",
                        timer, delay, intervalDuration);
                // schedule the task
                this.timerInjectedValue.getValue().scheduleAtFixedRate(task, delay, intervalDuration);
                // maintain it in timerservice for future use (like cancellation)
                this.scheduledTimerFutures.put(timer.getId(), task);
            } else {
                EJB3_TIMER_LOGGER.debugv("Scheduling a single action timer {0} starting at {1} milliseconds from now", timer, delay);
                // schedule the task
                this.timerInjectedValue.getValue().schedule(task, delay);
                // maintain it in timerservice for future use (like cancellation)
                this.scheduledTimerFutures.put(timer.getId(), task);

            }
        }
    }
protected void scheduleTimeout ( TimerImpl timer , boolean newTimer ) { synchronized ( scheduledTimerFutures ) { if ( ! newTimer && ! scheduledTimerFutures . containsKey ( timer . getId ( ) ) ) { //this timer has been cancelled by another thread. We just return return ; } Date nextExpiration = timer . getNextExpiration ( ) ; if ( nextExpiration == null ) { EJB3_TIMER_LOGGER . nextExpirationIsNull ( timer ) ; return ; } // create the timer task final TimerTask < ? > timerTask = timer . getTimerTask ( ) ; // find out how long is it away from now long delay = nextExpiration . getTime ( ) - System . currentTimeMillis ( ) ; // if in past, then trigger immediately if ( delay < 0 ) { delay = 0 ; } long intervalDuration = timer . getInterval ( ) ; final Task task = new Task ( timerTask , ejbComponentInjectedValue . getValue ( ) . getControlPoint ( ) ) ; if ( intervalDuration > 0 ) { EJB3_TIMER_LOGGER . debugv ( "Scheduling timer {0} at fixed rate, starting at {1} milliseconds from now with repeated interval={2}" , timer , delay , intervalDuration ) ; // schedule the task this . timerInjectedValue . getValue ( ) . scheduleAtFixedRate ( task , delay , intervalDuration ) ; // maintain it in timerservice for future use (like cancellation) this . scheduledTimerFutures . put ( timer . getId ( ) , task ) ; } else { EJB3_TIMER_LOGGER . debugv ( "Scheduling a single action timer {0} starting at {1} milliseconds from now" , timer , delay ) ; // schedule the task this . timerInjectedValue . getValue ( ) . schedule ( task , delay ) ; // maintain it in timerservice for future use (like cancellation) this . scheduledTimerFutures . put ( timer . getId ( ) , task ) ; } } }
Creates and schedules a {@link TimerTask} for the next timeout of the passed <code>timer</code>
Creates and schedules a {