org.oddjob.schedules
Class ScheduleCalculator

java.lang.Object
  extended by org.oddjob.schedules.ScheduleCalculator

public class ScheduleCalculator
extends Object

A class capable of calculating next due times for a job by using two schedules - a normal schedule for normal completion and a retry schedule for when a job hasn't completed.

Author:
Rob Gordon

Constructor Summary
ScheduleCalculator(Clock clock, Schedule schedule)
          Constructor for a calculator with no retry for the default time zone.
ScheduleCalculator(Clock clock, Schedule schedule, Schedule retry)
          Constructor for a calculator with a retry schedule using the default time zone.
ScheduleCalculator(Clock clock, Schedule schedule, Schedule retry, TimeZone timeZone)
          Constructor for a calculator with a retry schedule and a timeZone.
ScheduleCalculator(Clock clock, Schedule schedule, TimeZone timeZone)
          Constructor for a calculator with with a timeZone.
 
Method Summary
 void addScheduleListener(ScheduleListener l)
           
 void calculateComplete()
           
 void calculateRetry()
          Calculate the retry schedule.
protected  void fireComplete(ScheduleResult lastComplete)
           
protected  void fireFailed()
           
protected  void fireInitialised()
           
protected  void fireRetry(Interval limits)
           
 String getCurrentScheduleType()
          Get the name of the current schedule.
 Schedule getRetry()
          Getter for retry.
 Schedule getSchedule()
          Getter for schedule.
 void initialise()
           
 void initialise(ScheduleResult lastComplete, Map<Object,Object> contextData)
          Initialize the scheduler.
 void removeScheduleListener(ScheduleListener l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduleCalculator

public ScheduleCalculator(Clock clock,
                          Schedule schedule)
Constructor for a calculator with no retry for the default time zone.

Parameters:
clock - The clock to use, may not be null.
schedule - The normal schedule, may not be null.

ScheduleCalculator

public ScheduleCalculator(Clock clock,
                          Schedule schedule,
                          TimeZone timeZone)
Constructor for a calculator with with a timeZone.

Parameters:
clock - The clock to use, may not be null.
schedule - The normal schedule, may not be null.
timeZone - The time zone. May be null

ScheduleCalculator

public ScheduleCalculator(Clock clock,
                          Schedule schedule,
                          Schedule retry)
Constructor for a calculator with a retry schedule using the default time zone.

Parameters:
clock - The clock to use, may not be null.
schedule - The normal schedule, may not be null.
retry - The retrySchedule. May be null.

ScheduleCalculator

public ScheduleCalculator(Clock clock,
                          Schedule schedule,
                          Schedule retry,
                          TimeZone timeZone)
Constructor for a calculator with a retry schedule and a timeZone.

Parameters:
clock - The clock to use, may not be null.
schedule - The normal schedule, may not be null.
retry - The retrySchedule. May be null.
timeZone - The time zone. May be null
Method Detail

getSchedule

public Schedule getSchedule()
Getter for schedule.

Returns:
The schedule.

getRetry

public Schedule getRetry()
Getter for retry.

Returns:
The retry schedule.

initialise

public void initialise()

initialise

public void initialise(ScheduleResult lastComplete,
                       Map<Object,Object> contextData)
Initialize the scheduler.


getCurrentScheduleType

public String getCurrentScheduleType()
Get the name of the current schedule.

Returns:
The name of the current schedule.

calculateComplete

public void calculateComplete()

calculateRetry

public void calculateRetry()
Calculate the retry schedule.


addScheduleListener

public void addScheduleListener(ScheduleListener l)

removeScheduleListener

public void removeScheduleListener(ScheduleListener l)

fireInitialised

protected void fireInitialised()

fireComplete

protected void fireComplete(ScheduleResult lastComplete)

fireRetry

protected void fireRetry(Interval limits)

fireFailed

protected void fireFailed()