org.oddjob.jobs
Class WaitJob

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.framework.SimpleJob
              extended by org.oddjob.jobs.WaitJob
All Implemented Interfaces:
Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable

public class WaitJob
extends SimpleJob
implements Stoppable

Description

This Job will either wait a given number of milliseconds or will wait for a property or job to become available.

If the for property is provided, then the delay is used as the number of milliseconds between checking if the property is available.

Example

The ExecutorThrottleType has a simple example.

Example

This example waits for a variable 'text' to be set. The value could be set across the network or by a another job running in parallel.
<sequential name="Waiting For a Property">
    <jobs>
        <variables id="waitvars"/>
        <wait name="Wait for Variable" for="${waitvars.text}" pause="2000"/>
        <echo name="Echo Text">${waitvars.text}</echo>
    </jobs>
</sequential>
Author:
Rob Gordon

Field Summary
 
Fields inherited from class org.oddjob.framework.SimpleJob
stateHandler, stop
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
WaitJob()
           
 
Method Summary
 int execute()
          Execute this job.
 Object getFor()
           
 long getPause()
          Get the delay time in milli seconds.
 StateCondition getState()
           
 void setFor(Object forProperty)
           
 void setPause(long delay)
          Set the delay time in milli seconds.
 void setState(StateCondition state)
           
protected  void simpleWait()
           
protected  void waitFor()
           
protected  void waitForState()
           
 
Methods inherited from class org.oddjob.framework.SimpleJob
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, onReset, onStop, run, sleep, softReset, stateHandler, stop
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toString
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stoppable
stop
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Constructor Detail

WaitJob

public WaitJob()
Method Detail

setPause

public void setPause(long delay)
Set the delay time in milli seconds.

Parameters:
delay - The delay time.

getPause

public long getPause()
Get the delay time in milli seconds.

Returns:
The delay time.

execute

public int execute()
            throws Exception
Description copied from class: SimpleJob
Execute this job.

Specified by:
execute in class SimpleJob
Returns:
0 if the job is complete, anything else otherwise.
Throws:
Exception - If the unexpected occurs.

simpleWait

protected void simpleWait()

waitFor

protected void waitFor()

waitForState

protected void waitForState()

getFor

public Object getFor()

setFor

public void setFor(Object forProperty)

getState

public StateCondition getState()

setState

public void setState(StateCondition state)