Package org.oddjob.framework.extend
Class StructuralJob<E>
java.lang.Object
org.oddjob.framework.extend.BaseComponent
org.oddjob.framework.extend.BasePrimary
org.oddjob.framework.extend.StructuralJob<E>
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
- Direct Known Subclasses:
BasicBusService,CascadeJob,EqualsState,EventJobBase,ForEachJob,IfJob,JoinJob,MultiExplorerLauncher,Oddjob,RepeatJob,Resets,RunJob,SequentialJob,SimultaneousStructural,SplitDestinations,SwitchJob
public abstract class StructuralJob<E>
extends BasePrimary
implements Runnable, Serializable, Stoppable, Resettable, Stateful, Forceable, Structural
An abstract implementation of a job which provides common functionality to
concrete sub classes.
- Author:
- Rob Gordon
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChildHelper<E> Track changes to children an notify listeners.protected booleanprotected booleanprotected StructuralStateHelperCalculate our state based on children. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStructuralListener(StructuralListener listener) Add a listener.protected abstract voidexecute()Execute this job.protected voidInternal method to fire state.voidforce()Force the job to COMPLETE.protected abstract StateOperatorSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.protected final StateChanger<ParentState> booleanPerform a hard reset on the job.protected IconHelperSubclasses must provide aIconHelper.booleanisStop()Expose the internal stop flag as a read only property.protected voidSubclasses override this method to clear up resources.protected voidAllow sub classes to do something on HARD reset.protected voidonReset()Allow sub classes to do something on reset.protected voidAllow sub classes to do something on SOFT reset.protected voidonStop()Allow sub classes to do something on stop.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 voidStart the child state reflector.protected ParentStateHandlerSubclasses must provide aStateHandler.voidstop()Implementation for a typical stop.protected voidprotected booleanMethods 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
-
childHelper
Track changes to children an notify listeners. -
structuralState
Calculate our state based on children. -
stop
protected transient volatile boolean stop- Reference Property:
Description
Read only view of the internal stop flag. This flag is cleared with a reset. -
destroy
protected transient volatile boolean destroy
-
-
Constructor Details
-
StructuralJob
public StructuralJob()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
-
getInitialStateOp
Subclasses must provide theStateOperatorthat will decide how to evaluate the children's state.- Returns:
- A State Operator. Must not be null.
-
execute
Execute this job. -
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. -
startChildStateReflector
protected void startChildStateReflector()Start the child state reflector. Sub classes override this if they need to start the child state reflector at a different time. -
stopChildStateReflector
protected void stopChildStateReflector() -
waitForChildrenOnStop
protected boolean waitForChildrenOnStop() -
stop
Implementation for a typical stop.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
Allow sub classes to do something on stop.- Throws:
FailedToStopException
-
postStop
Subclasses can override to perform actions once children have stopped.- Throws:
FailedToStopException
-
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.
-
onHardReset
protected void onHardReset()Allow sub classes to do something on HARD reset. -
onSoftReset
protected void onSoftReset()Allow sub classes to do something on SOFT reset. -
onReset
protected void onReset()Allow sub classes to do something on reset. -
force
public void force()Force the job to COMPLETE. -
addStructuralListener
Add a listener. The listener will immediately receive 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 listener.
-
isStop
public boolean isStop()Expose the internal stop flag as a read only property.- Returns:
- the stop flag.
-
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
-