org.oddjob.state
Class JoinJob

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.JoinJob
All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural

public class JoinJob
extends StructuralJob<Runnable>

Description

Waits for a COMPLETE state from it's child job before allowing the thread of execution to continue.

Example

An join that waits for two triggers. In this example another trigger to run the last job might be a better solution because it wouldn't hog a thread - but there are situations when join is just simpler.
<oddjob>
    <job>
        <sequential>
            <jobs>
                <folder>
                    <jobs>
                        <state:flag id="apples" xmlns:state="http://rgordon.co.uk/oddjob/state"/>
                        <state:flag id="oranges" xmlns:state="http://rgordon.co.uk/oddjob/state"/>
                    </jobs>
                </folder>
                <state:join id="our-join" xmlns:state="http://rgordon.co.uk/oddjob/state">
                    <job>
                        <sequential>
                            <jobs>
                                <scheduling:trigger on="${apples}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                                    <job>
                                        <echo>Apples</echo>
                                    </job>
                                </scheduling:trigger>
                                <scheduling:trigger on="${oranges}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                                    <job>
                                        <echo>Oranges</echo>
                                    </job>
                                </scheduling:trigger>
                            </jobs>
                        </sequential>
                    </job>
                </state:join>
                <echo id="last-job">And that's that!</echo>
            </jobs>
        </sequential>
    </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
JoinJob()
           
 
Method Summary
protected  void execute()
          Execute this job.
protected  StateOperator getInitialStateOp()
          Subclasses must provide the StateOperator that will decide how to evaluate the children's state.
 void setJob(Runnable child)
          Set the child job.
 
Methods inherited from class org.oddjob.framework.StructuralJob
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, isStop, onDestroy, onReset, onStop, removeStructuralListener, run, softReset, startChildStateReflector, 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

JoinJob

public JoinJob()
Method Detail

setJob

public void setJob(Runnable child)
Set the child job.

Property: job

Description: The child job.

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

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<Runnable>
Returns:
A State Operator. Must not be null.