public class SequentialJob extends StructuralJob<Object> implements Structural, Stoppable, OptionallyTransient
This behaviour can be changed by setting the independent
property which will cause execution to continue regardless of the last
executed child state.
stateOperator
property changes the way in which
this jobs state reflects its child states. Oddjob currently supports the
following State Operators:
transient
property to true. Not that when starting
services with this job, persistence is probably not desirable as
it will stop the services from re-starting.
<oddjob> <job> <sequential name="A sequence of two jobs"> <jobs> <echo>This runs first.</echo> <echo>This runs after.</echo> </jobs> </sequential> </job> </oddjob>
<oddjob> <job> <sequential> <jobs> <sequential id="service-manager" stateOperator="SERVICES"> <jobs> <bean id="lights" class="org.oddjob.jobs.structural.ServiceManagerTest$Lights"/> <bean id="machine" class="org.oddjob.jobs.structural.ServiceManagerTest$MachineThatGoes" goes="ping"/> </jobs> </sequential> <echo>The lights are ${lights.are} and the machine goes ${machine.goes}.</echo> </jobs> </sequential> </job> </oddjob>The services are started in order. Once both services have started a job is performed that requires both services. If this configuration were running from the command line, Oddjob would stop the services as it shut down. First the machine would be turned of and then finally the lights would be turned out.
childHelper, childStateReflector, destroy, stop, structuralState
Constructor and Description |
---|
SequentialJob() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Execute this job.
|
protected StateOperator |
getInitialStateOp()
Subclasses must provide the
StateOperator that will decide
how to evaluate the children's state. |
StateOperator |
getStateOperator() |
boolean |
isIndependent() |
boolean |
isTransient()
Is the component transient.
|
void |
setIndependent(boolean independent)
Set whether children are considered dependent (false, default)
or independent (true).
|
void |
setJobs(int index,
Object child)
Add a child.
|
void |
setStateOperator(StateOperator stateOperator) |
void |
setTransient(boolean _transient) |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, onStop, removeStructuralListener, run, softReset, startChildStateReflector, stateHandler, stop
configure, getName, logger, logger, loggerName, save, setName, toString
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStructuralListener, removeStructuralListener
addStateListener, lastStateEvent, removeStateListener
public void setStateOperator(StateOperator stateOperator)
Property: stateOperator
Description: Set the way the children's state is evaluated and reflected by the parent. Values can be WORST, ACTIVE, or SERVICES.
Required: No, default is WORST.
stateOperator
- The state operator to be applied to children's
states to derive our state.public StateOperator getStateOperator()
protected StateOperator getInitialStateOp()
StructuralJob
StateOperator
that will decide
how to evaluate the children's state.getInitialStateOp
in class StructuralJob<Object>
public void setJobs(int index, Object child)
Property: jobs
Description: The child jobs.
Required: No, but pointless if missing.
child
- A childpublic void execute() throws Exception
StructuralJob
execute
in class StructuralJob<Object>
Exception
- If the unexpected occurs.public boolean isIndependent()
public void setIndependent(boolean independent)
Property: independent
Description: Whether the child jobs are independent or not.
Required: Default is dependent child jobs.
independent
- flag value to setpublic boolean isTransient()
OptionallyTransient
isTransient
in interface OptionallyTransient
public void setTransient(boolean _transient)