org.oddjob.state
Class CascadeJob

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.framework.StructuralJob<Runnable>
              extended by org.oddjob.state.CascadeJob
All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural

public class CascadeJob
extends StructuralJob<Runnable>

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.

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>
See Also:
Serialized Form
Author:
Rob Gordon

Field Summary
 
Fields inherited from class org.oddjob.framework.StructuralJob
childHelper, childStateReflector, stateHandler, stop, structuralState
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
CascadeJob()
           
 
Method Summary
 void addStructuralListener(StructuralListener listener)
          Add a listener.
protected  void execute()
          Execute this job.
protected  StateOperator getStateOp()
           
protected  void onStop()
          Allow sub classes to do something on stop.
 void removeStructuralListener(StructuralListener listener)
          Remove a listener.
 void setExecutorService(ExecutorService executor)
           
 void setJobs(int index, Runnable child)
          Add a child job.
protected  void startChildStateReflector()
           
 
Methods inherited from class org.oddjob.framework.StructuralJob
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, onReset, run, softReset, stateHandler, stop
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toString
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Constructor Detail

CascadeJob

public CascadeJob()
Method Detail

setExecutorService

@Inject
public void setExecutorService(ExecutorService executor)

setJobs

public void setJobs(int index,
                    Runnable 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<Runnable>
Throws:
InterruptedException

onStop

protected void onStop()
Description copied from class: StructuralJob
Allow sub classes to do something on stop.

Overrides:
onStop in class StructuralJob<Runnable>

getStateOp

protected StateOperator getStateOp()
Specified by:
getStateOp in class StructuralJob<Runnable>

addStructuralListener

public void addStructuralListener(StructuralListener listener)
Description copied from class: StructuralJob
Add a listener. The listener will immediately receive add notifications for all existing children.

Specified by:
addStructuralListener in interface Structural
Overrides:
addStructuralListener in class StructuralJob<Runnable>
Parameters:
listener - The listener.

removeStructuralListener

public void removeStructuralListener(StructuralListener listener)
Description copied from class: StructuralJob
Remove a listener.

Specified by:
removeStructuralListener in interface Structural
Overrides:
removeStructuralListener in class StructuralJob<Runnable>
Parameters:
listener - The listener.

startChildStateReflector

protected void startChildStateReflector()
Overrides:
startChildStateReflector in class StructuralJob<Runnable>