public class EqualsState extends StructuralJob<Stateful> implements Stoppable
This job is probably most useful in it's 'not equals' form - i.e. to check when something hasn't completed.
state:equals
job can be used to reverse
the meaning of the exists
job. A request to
shutdown a database may complete asynchronously, and the only
way to tell if shutdown is complete is to check that the Database's
lock file has be removed. This example demonstrates how Oddjob
can check for this situation
before attempting to back up the database.
<oddjob id="this"> <job> <scheduling:retry name="Database Backup" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling"> <schedule> <schedules:interval interval="00:00:02" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/> </schedule> <job> <sequential id="db-backup"> <jobs> <state:equals state="!COMPLETE" xmlns:state="http://rgordon.co.uk/oddjob/state"> <job> <state:resets harden="true"> <job> <exists file="${db.lock.file}"/> </job> </state:resets> </job> </state:equals> <echo>Backing up the Database...</echo> </jobs> </sequential> </job> </scheduling:retry> </job> </oddjob>
childHelper, destroy, stop, structuralState
Constructor and Description |
---|
EqualsState() |
Modifier and Type | Method and Description |
---|---|
protected void |
execute()
Execute this job.
|
protected StateOperator |
getInitialStateOp()
Subclasses must provide the
StateOperator that will decide
how to evaluate the children's state. |
StateCondition |
getState() |
void |
setJob(Stateful job) |
void |
setState(StateCondition state) |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, onStop, postStop, removeStructuralListener, run, softReset, startChildStateReflector, stateHandler, stop, stopChildStateReflector, waitForChildrenOnStop
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
addStateListener, lastStateEvent, removeStateListener
public StateCondition getState()
public void setState(StateCondition state)
protected StateOperator getInitialStateOp()
StructuralJob
StateOperator
that will decide
how to evaluate the children's state.getInitialStateOp
in class StructuralJob<Stateful>
public void setJob(Stateful job)
Property: job
Description: The job to run who's state will be compared.
Required: Yes.
protected void execute() throws java.lang.Throwable
StructuralJob
execute
in class StructuralJob<Stateful>
java.lang.Exception
- If the unexpected occurs.java.lang.Throwable