org.springframework.integration.scheduling
Class IntervalTrigger

java.lang.Object
  extended by org.springframework.integration.scheduling.IntervalTrigger
All Implemented Interfaces:
Trigger

public class IntervalTrigger
extends java.lang.Object
implements Trigger

A trigger for periodic execution. The interval may be applied as either fixed-rate or fixed-delay, and an initial delay value may also be configured. The default initial delay is 0, and the default behavior is fixed-delay: each subsequent delay is measured from the last completion time. To enable execution between the scheduled start time of each execution, set 'fixedRate' to true.

Author:
Mark Fisher

Constructor Summary
IntervalTrigger(long interval)
          Create a trigger with the given interval in milliseconds.
IntervalTrigger(long interval, java.util.concurrent.TimeUnit timeUnit)
          Create a trigger with the given interval and time unit.
 
Method Summary
 java.util.Date getNextRunTime(java.util.Date lastScheduledRunTime, java.util.Date lastCompleteTime)
          Returns the next time a task should run.
 void setFixedRate(boolean fixedRate)
          Specify whether the interval should be measured between the scheduled start times rather than between actual completion times (the latter, "fixed delay" behavior, is the default).
 void setInitialDelay(long initialDelay)
          Specify the delay for the initial execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntervalTrigger

public IntervalTrigger(long interval)
Create a trigger with the given interval in milliseconds.


IntervalTrigger

public IntervalTrigger(long interval,
                       java.util.concurrent.TimeUnit timeUnit)
Create a trigger with the given interval and time unit.

Method Detail

setInitialDelay

public void setInitialDelay(long initialDelay)
Specify the delay for the initial execution.


setFixedRate

public void setFixedRate(boolean fixedRate)
Specify whether the interval should be measured between the scheduled start times rather than between actual completion times (the latter, "fixed delay" behavior, is the default).


getNextRunTime

public java.util.Date getNextRunTime(java.util.Date lastScheduledRunTime,
                                     java.util.Date lastCompleteTime)
Returns the next time a task should run.

Specified by:
getNextRunTime in interface Trigger
Parameters:
lastScheduledRunTime - last time the relevant task was scheduled to run, or null if it has never been scheduled
lastCompleteTime - last time the relevant task finished or null if it did not run to completion
Returns:
next time that a task should run