org.springframework.scheduling.timer
Class ScheduledTimerTask

java.lang.Object
  extended byorg.springframework.scheduling.timer.ScheduledTimerTask

public class ScheduledTimerTask
extends java.lang.Object

JavaBean that describes a scheduled TimerTask, consisting of the TimerTask itself and a delay plus period. Period needs to be specified; there is no point in a default for it.

The J2SE Timer does not offer more sophisticated scheduling options like cron expressions. Consider using Quartz for such demanding needs.

Note that Timer uses a TimerTask instance that is shared between repeated executions, in contrast to Quartz which instantiates a new Job for each execution.

Since:
19.02.2004
Author:
Juergen Hoeller
See Also:
TimerTask, Timer.schedule(TimerTask, long, long), Timer.scheduleAtFixedRate(TimerTask, long, long)

Constructor Summary
ScheduledTimerTask()
           
ScheduledTimerTask(java.util.TimerTask timerTask, long delay, long period, boolean fixedRate)
           
 
Method Summary
 long getDelay()
          Return the delay before starting the job for the first time.
 long getPeriod()
          Return the period between repeated task executions.
 java.util.TimerTask getTimerTask()
          Return the TimerTask to schedule.
 boolean isFixedRate()
          Return whether to schedule as fixed-rate execution.
 void setDelay(long delay)
          Set the delay before starting the task for the first time, in milliseconds.
 void setFixedRate(boolean fixedRate)
          Set whether to schedule as fixed-rate execution, rather than fixed-delay execution.
 void setPeriod(long period)
          Set the period between repeated task executions, in milliseconds.
 void setTimerTask(java.util.TimerTask timerTask)
          Set the TimerTask to schedule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduledTimerTask

public ScheduledTimerTask()

ScheduledTimerTask

public ScheduledTimerTask(java.util.TimerTask timerTask,
                          long delay,
                          long period,
                          boolean fixedRate)
Method Detail

setTimerTask

public void setTimerTask(java.util.TimerTask timerTask)
Set the TimerTask to schedule.


getTimerTask

public java.util.TimerTask getTimerTask()
Return the TimerTask to schedule.


setDelay

public void setDelay(long delay)
Set the delay before starting the task for the first time, in milliseconds. Default is 0, immediately starting the task after successful scheduling.


getDelay

public long getDelay()
Return the delay before starting the job for the first time.


setPeriod

public void setPeriod(long period)
Set the period between repeated task executions, in milliseconds. Default is 0; this property needs to be set to a positive value for proper execution.


getPeriod

public long getPeriod()
Return the period between repeated task executions.


setFixedRate

public void setFixedRate(boolean fixedRate)
Set whether to schedule as fixed-rate execution, rather than fixed-delay execution. Default is false, i.e. fixed delay. See Timer javadoc for details on those execution modes.

See Also:
Timer.schedule(TimerTask, long, long), Timer.scheduleAtFixedRate(TimerTask, long, long)

isFixedRate

public boolean isFixedRate()
Return whether to schedule as fixed-rate execution.



Copyright (C) 2003-2004 The Spring Framework Project.