Package org.oddjob.scheduling
Class ScheduleBase
java.lang.Object
org.oddjob.framework.extend.BaseComponent
org.oddjob.framework.extend.BasePrimary
org.oddjob.scheduling.ScheduleBase
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
public abstract class ScheduleBase
extends BasePrimary
implements Runnable, Stoppable, Serializable, Resettable, Stateful, Structural, Forceable
Common functionality for jobs that schedule things.
- Author:
- Rob Gordon
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CountDownLatchprotected ChildHelper<Runnable> Track the child.protected StateExchange<TimerState> protected TimerStateHandlerFires state events.protected booleanStop flag. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStructuralListener(StructuralListener listener) Add a listener.protected abstract voidbegin()Sub classes must override this to submit the first execution.protected voidInternal method to fire state.voidforce()Force something.protected StateChanger<TimerState> protected abstract StateOperatorSub classes provide the state operator that is used to calculate the subclasses completion state.booleanPerform a hard reset on the job.protected IconHelperSubclasses must provide aIconHelper.protected voidSubclasses override this method to clear up resources.protected 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.voidremoveStructuralListener(StructuralListener listener) Remove a listener.final voidrun()Implement the main execute method for a job.booleanPerform a soft reset on the job.protected TimerStateHandlerSubclasses must provide aStateHandler.final voidstop()Implementation for a typical stop.Methods 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
-
stateHandler
Fires state events. -
childHelper
Track the child. -
childStateReflector
-
stop
protected transient volatile boolean stopStop flag. -
begun
-
-
Constructor Details
-
ScheduleBase
public ScheduleBase()Default Constructor.
-
-
Method Details
-
stateHandler
Description copied from class:BaseComponentSubclasses must provide aStateHandler.- Specified by:
stateHandlerin classBaseComponent- Returns:
- A State Handler. Never null.
-
iconHelper
Description copied from class:BaseComponentSubclasses must provide aIconHelper.- Specified by:
iconHelperin classBaseComponent- Returns:
- An Icon Helper. Never null.
-
getStateChanger
-
getStateOp
Sub classes provide the state operator that is used to calculate the subclasses completion state.- Returns:
- The operator. Must not be null.
-
begin
Sub classes must override this to submit the first execution.- Throws:
ComponentPersistException- If the scheduled time can't be saved.
-
run
public final void run()Implement the main execute method for a job. This surrounds the doExecute method of the sub class and sets state for the job. -
stop
Implementation for a typical stop. Subclasses must implement Stoppable to take advantage of it.This stop implementation doesn't check that the job is executing as stop messages must cascade down the hierarchy to manually started jobs.
- Specified by:
stopin interfaceStoppable- Throws:
FailedToStopException
-
onStop
protected void onStop()Subclasses can override to perform stopping operations. -
postStop
protected void postStop()Subclasses can override to perform actions once children have stopped. -
softReset
public boolean softReset()Perform a soft reset on the job.- Specified by:
softResetin interfaceResettable- Returns:
- true if successful.
-
hardReset
public boolean hardReset()Perform a hard reset on the job.- Specified by:
hardResetin interfaceResettable- Returns:
- true if successful.
-
onReset
protected void onReset()Override by subclasses to reset state. -
force
public void force()Description copied from interface:ForceableForce something. Generally this will be the state of a job to COMPLETE but other uses may be found. -
addStructuralListener
Add a listener. The listener will immediately recieve add notifications for all existing children.- Specified by:
addStructuralListenerin interfaceStructural- Parameters:
listener- The listener.
-
removeStructuralListener
Remove a listener.- Specified by:
removeStructuralListenerin interfaceStructural- Parameters:
listener- The listner.
-
onDestroy
protected void onDestroy()Description copied from class:BaseComponentSubclasses override this method to clear up resources. This is called by the framework before child elements have been destroyed.- Overrides:
onDestroyin classBaseComponent
-
fireDestroyedState
protected void fireDestroyedState()Internal method to fire state.- Specified by:
fireDestroyedStatein classBaseComponent
-