org.oddjob.state
Class EqualsState
java.lang.Object
org.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.StructuralJob<Stateful>
org.oddjob.state.EqualsState
- All Implemented Interfaces:
- Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural
public class EqualsState
- extends StructuralJob<Stateful>
- implements Stoppable
Description
Runs it's child job and then compares the state of the child job to
the given state. It's own state is complete if the states match,
incomplete otherwise.
This job is probably most useful in it's 'not equals' form - i.e. to
check when something hasn't completed.
Example
COMPLETE when the child job isn't complete. This example
demonstrates how the 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>
- See Also:
- Serialized Form
- Author:
- Rob Gordon
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.BaseComponent |
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
EqualsState
public EqualsState()
getState
public StateCondition getState()
setState
public void setState(StateCondition state)
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<Stateful>
- Returns:
- A State Operator. Must not be null.
setJob
public void setJob(Stateful job)
Property: job
Description: The job to run who's state will be compared.
Required: Yes.
execute
protected void execute()
throws Throwable
- Description copied from class:
StructuralJob
- Execute this job.
- Specified by:
execute
in class StructuralJob<Stateful>
- Throws:
Exception
- If the unexpected occurs.
Throwable