org.oddjob.state
Class CascadeJob
java.lang.Object
org.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.StructuralJob<Object>
org.oddjob.state.CascadeJob
- All Implemented Interfaces:
- Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural
public class CascadeJob
- extends StructuralJob<Object>
Description
A job which triggers the next job after the previous one completes.
This job differs from a SequentialJob
task in that the latter
follows the thread of execution, and only checks state to ensure
it can continue. This job's thread of execution passes onwards after the
cascade has been set up. This job will complete asynchronously once all
it's children have completed.
State Operator
This job doesn't currently expose a State Operator property as
SequentialJob
does. The state behaviour is equivalent to the
WORST state operator, which is what is desired in most situations. A
stateOperator
property may be added in future versions
if needed.Example
A cascade of two jobs.
<oddjob>
<job>
<state:cascade xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<echo>This runs first.</echo>
<echo>Then this.</echo>
</jobs>
</state:cascade>
</job>
</oddjob>
Example
Showing cascade being used with ParallelJob
. The cascade will
wait for the parallel job to finish before running the third job.
<oddjob>
<job>
<state:cascade xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<parallel>
<jobs>
<echo>Oranges could be first or second.</echo>
<echo>Pears could be first or second.</echo>
</jobs>
</parallel>
<echo>Apples are guaranteed to be third.</echo>
</jobs>
</state:cascade>
</job>
</oddjob>
- See Also:
- Serialized Form
- Author:
- Rob Gordon
Methods inherited from class org.oddjob.framework.StructuralJob |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, isStop, onDestroy, onReset, removeStructuralListener, run, softReset, stateHandler, stop |
Methods inherited from class org.oddjob.framework.BaseComponent |
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
CascadeJob
public CascadeJob()
setExecutorService
@Inject
public void setExecutorService(ExecutorService executor)
setJobs
public void setJobs(int index,
Object child)
- Add a child job.
Property: jobs
Description: The child jobs.
Required: No, but pointless if missing.
- Parameters:
child
- A child
execute
protected void execute()
throws InterruptedException
- Description copied from class:
StructuralJob
- Execute this job.
- Specified by:
execute
in class StructuralJob<Object>
- Throws:
InterruptedException
onStop
protected void onStop()
- Description copied from class:
StructuralJob
- Allow sub classes to do something on stop.
- Overrides:
onStop
in class StructuralJob<Object>
getInitialStateOp
protected StateOperator getInitialStateOp()
- Description copied from class:
StructuralJob
- Subclasses must provide the
StateOperator
that will decide
how to evaluate the children's state.
- Specified by:
getInitialStateOp
in class StructuralJob<Object>
- Returns:
- A State Operator. Must not be null.
startChildStateReflector
protected void startChildStateReflector()
- Overrides:
startChildStateReflector
in class StructuralJob<Object>