Package org.oddjob.state
Class EqualsState
- All Implemented Interfaces:
Serializable,Runnable,ArooaContextAware,ArooaSessionAware,Forceable,PropertyChangeNotifier,Iconic,LogEnabled,Resettable,Stateful,Stoppable,Structural
- Author:
- Rob Gordon
- See Also:
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 thestate: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>
-
Field Summary
Fields inherited from class org.oddjob.framework.extend.StructuralJob
childHelper, destroy, stop, structuralState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexecute()Execute this job.protected StateOperatorSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.getState()voidvoidsetState(StateCondition state) Methods inherited from class org.oddjob.framework.extend.StructuralJob
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onReset, onSoftReset, onStop, postStop, removeStructuralListener, run, softReset, startChildStateReflector, stateHandler, stop, stopChildStateReflector, waitForChildrenOnStopMethods inherited from class org.oddjob.framework.extend.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toStringMethods inherited from class org.oddjob.framework.extend.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
-
Constructor Details
-
EqualsState
public EqualsState()
-
-
Method Details
-
getState
-
setState
-
getInitialStateOp
Description copied from class:StructuralJobSubclasses must provide theStateOperatorthat will decide how to evaluate the children's state.- Specified by:
getInitialStateOpin classStructuralJob<Stateful>- Returns:
- A State Operator. Must not be null.
-
setJob
- Reference Property:
- job
- Required:
- Yes.
Description
The job to run who's state will be compared. -
execute
Description copied from class:StructuralJobExecute this job.- Specified by:
executein classStructuralJob<Stateful>- Throws:
Throwable
-