public class IfJob extends StructuralJob<java.lang.Object> implements java.lang.Runnable, Stateful, Resetable, Structural, Stoppable
The completion state is that of the then or else job. If either don't exist then the Job is flagged as complete.
If any more than three jobs are provided the extra jobs are ignored.
If the first job enters an ACTIVE state then condition will not be evaluated until the first job leaves the ACTIVE state. This job will not block while this is happening. The thread of execution will pass to its next sibling and this job will also enter the ACTIVE state.
<oddjob id="this" xmlns:state="http://rgordon.co.uk/oddjob/state"> <job> <state:if> <jobs> <exists name="Check File Exists" file="${this.dir}/data/some.txt"/> <echo id="then" name="Echo to Console">File Exists</echo> <echo id="else" name="Echo to Console">File Doesn't Exist</echo> </jobs> </state:if> </job> </oddjob>
<oddjob> <job> <sequential xmlns:state="http://rgordon.co.uk/oddjob/state"> <jobs> <state:if> <jobs> <echo>Hello</echo> <echo>Good Bye</echo> </jobs> </state:if> <state:if> <jobs> <state:flag name="Exception" state="EXCEPTION"/> <state:flag name="Unexpected 1" state="EXCEPTION"/> <echo>No Hello</echo> </jobs> </state:if> <state:if> <jobs> <echo>Only Hello</echo> </jobs> </state:if> <state:if state="!COMPLETE"> <jobs> <state:flag name="Exception" state="EXCEPTION"/> <echo>No Hello</echo> </jobs> </state:if> <state:if state="!COMPLETE"> <jobs> <echo>Hello</echo> <state:flag name="Unexpected 2" state="EXCEPTION"/> </jobs> </state:if> <state:if state="!EXCEPTION"> <jobs> <echo>Hello</echo> <echo>Good Bye</echo> <state:flag name="Unexpected 3" state="EXCEPTION"/> </jobs> </state:if> </jobs> </sequential> </job> </oddjob>
<oddjob> <job> <state:if id="if-job" xmlns:state="http://rgordon.co.uk/oddjob/state"> <jobs> <parallel> <jobs> <state:flag/> </jobs> </parallel> <echo id="then-job">That Worked!</echo> <echo id="else-job">This should never be shown.</echo> </jobs> </state:if> </job> </oddjob>
childHelper, destroy, stop, structuralState
Constructor and Description |
---|
IfJob() |
Modifier and Type | Method and Description |
---|---|
protected java.util.concurrent.ExecutorService |
ensureExecutorService() |
protected void |
execute()
Execute this job.
|
java.util.concurrent.ExecutorService |
getExecutorService() |
protected StateOperator |
getInitialStateOp()
Subclasses must provide the
StateOperator that will decide
how to evaluate the children's state. |
StateCondition |
getState()
Getter for state.
|
protected void |
onStop()
Allow sub classes to do something on stop.
|
void |
setArooaContext(ArooaContext context) |
void |
setExecutorService(java.util.concurrent.ExecutorService executorService) |
void |
setJobs(int index,
java.lang.Object job) |
void |
setState(StateCondition state) |
protected void |
startChildStateReflector()
Start the child state reflector.
|
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, postStop, removeStructuralListener, run, softReset, stateHandler, stop, stopChildStateReflector
configure, getName, logger, logger, loggerName, save, setName, toString
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStateListener, lastStateEvent, removeStateListener
addStructuralListener, removeStructuralListener
public void setArooaContext(ArooaContext context)
setArooaContext
in interface ArooaContextAware
setArooaContext
in class BaseComponent
public StateCondition getState()
public void setState(StateCondition state)
Property: state
Description: The state condition to check against. See the Oddjob User guide for a full list of state conditions.
Required: No, defaults to COMPLETE.
public void setJobs(int index, java.lang.Object job)
Property: jobs
Description: The child jobs.
Required: At least one.
protected StateOperator getInitialStateOp()
StructuralJob
StateOperator
that will decide
how to evaluate the children's state.getInitialStateOp
in class StructuralJob<java.lang.Object>
protected void execute()
StructuralJob
execute
in class StructuralJob<java.lang.Object>
protected void onStop() throws FailedToStopException
StructuralJob
onStop
in class StructuralJob<java.lang.Object>
FailedToStopException
protected void startChildStateReflector()
StructuralJob
startChildStateReflector
in class StructuralJob<java.lang.Object>
protected java.util.concurrent.ExecutorService ensureExecutorService()
public java.util.concurrent.ExecutorService getExecutorService()
public void setExecutorService(java.util.concurrent.ExecutorService executorService)