Package org.oddjob.scheduling
Class TimerBase
java.lang.Object
org.oddjob.framework.extend.BaseComponent
org.oddjob.framework.extend.BasePrimary
org.oddjob.scheduling.ScheduleBase
org.oddjob.scheduling.TimerBase
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
Common functionality for Timers.
- Author:
- rob
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionProvided to the schedule.Fields inherited from class org.oddjob.scheduling.ScheduleBase
begun, childHelper, childStateReflector, stateHandler, stop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbegin()Sub classes must override this to submit the first execution.protected voidCancel and child jobs that are submitted and stop any that are running.protected booleanchangeStateLocked(TimerState required) getClock()Get the current clock.Get the current/next interval.protected abstract StateConditionprotected abstract ResetActionGet the last due date.protected abstract IntervalImplementation provided by sub classes so limits are available inscheduleFrom(Date).Get the next due date.getReset()Get the time zone id to use in this schedule.protected voidhandleChildState(StateEvent event, StateListener listener) protected booleaninternalSetNextDue(Date nextDue) Set the next due date.protected abstract booleanprotected voidonReset()Override by subclasses to reset state.protected voidonStop()Subclasses can override to perform stopping operations.protected voidpostStop()Subclasses can override to perform actions once children have stopped.protected booleanReschedule a job.protected voidreset(Resettable job) Implementation provided by sub classes to decide what kind of reset to send to the child.protected booleanscheduleFrom(Date date) Schedule a job from a given date.voidSet the clock.voidsetHaltOn(StateCondition haltOn) voidvoidsetNextDue(Date nextDue) Manually set the Next Due Date.voidsetReschedule(Date reSchedule) voidsetReset(ResetAction reset) voidsetSchedule(Schedule schedule) Set the schedule.voidvoidsetTimeZone(String timeZoneId) Set the time zone.Methods inherited from class org.oddjob.scheduling.ScheduleBase
addStructuralListener, fireDestroyedState, force, getStateChanger, getStateOp, hardReset, iconHelper, onDestroy, removeStructuralListener, run, softReset, stateHandler, stopMethods inherited from class org.oddjob.framework.extend.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toStringMethods inherited from class org.oddjob.framework.extend.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
-
Field Details
-
contextData
Provided to the schedule.
-
-
Constructor Details
-
TimerBase
public TimerBase()
-
-
Method Details
-
setScheduleExecutorService
-
begin
Description copied from class:ScheduleBaseSub classes must override this to submit the first execution.- Specified by:
beginin classScheduleBase- Throws:
ComponentPersistException- If the scheduled time can't be saved.
-
onStop
protected void onStop()Description copied from class:ScheduleBaseSubclasses can override to perform stopping operations.- Overrides:
onStopin classScheduleBase
-
postStop
protected void postStop()Description copied from class:ScheduleBaseSubclasses can override to perform actions once children have stopped.- Overrides:
postStopin classScheduleBase
-
onReset
protected void onReset()Description copied from class:ScheduleBaseOverride by subclasses to reset state.- Overrides:
onResetin classScheduleBase
-
getTimeZone
Get the time zone id to use in this schedule.- Returns:
- The time zone id being used.
-
setTimeZone
Set the time zone.- Parameters:
timeZoneId- the timeZoneId.
-
setSchedule
Set the schedule.- Parameters:
schedule- The schedule.
-
getSchedule
-
setReschedule
- Throws:
OddjobLockedException- Reference Property:
- reschedule
- Required:
- Only available once the timer has started.
Description
Reschedule from the given date/time. -
CancelAndStopChild
Cancel and child jobs that are submitted and stop any that are running. This should only be run while locked because it temporarily sets the stop flag to fool the state listener into not rescheduling.- Throws:
FailedToStopException
-
scheduleFrom
Schedule a job from a given date.- Parameters:
date- The date to schedule the job from.- Returns:
- true if the job is scheduled again, false if it is not to be scheduled again.
- Throws:
ComponentPersistException
-
getClock
Get the current clock.- Returns:
- The clock
-
setClock
Set the clock. Only useful for testing.- Parameters:
clock- The clock.
-
setNextDue
Manually set the Next Due Date.- Parameters:
nextDue- The Next Due Date. May be null.- Throws:
OddjobLockedException
-
getNextDue
Get the next due date.- Returns:
- The next due date
-
internalSetNextDue
Set the next due date.- Parameters:
nextDue- The date schedule is next due. If null the job won't be scheduled and the child state reflector will be called to reflect the state of the child job.- Returns:
- true if the job was scheduled. False it wasn't.
- Throws:
ComponentPersistException
-
getCurrent
Get the current/next interval.- Returns:
- The interval, null if not due again.
-
getLastDue
Get the last due date.- Returns:
- The last due date, null when a timer starts for the first time.
-
setJob
- Reference Property:
- job
- Required:
- Yes.
Description
The job to run when it's due. -
getLimits
Implementation provided by sub classes so limits are available inscheduleFrom(Date).- Returns:
- The limits, or null. Retry has limits, timer doesn't.
-
reschedule
Reschedule a job.- Returns:
- True if it was schedule, false if it wasn't.
- Throws:
ComponentPersistException
-
reset
Implementation provided by sub classes to decide what kind of reset to send to the child. Timer sends a hard reset, Retry sends a soft reset.- Parameters:
job- The child job that will be reset.
-
handleChildState
protected void handleChildState(StateEvent event, StateListener listener) throws ComponentPersistException - Throws:
ComponentPersistException
-
changeStateLocked
-
getHaltOn
-
setHaltOn
-
getDefaultHaltOn
-
isSkipMissedRuns
protected abstract boolean isSkipMissedRuns() -
getReset
-
setReset
-
getDefaultReset
-