org.apache.tools.ant.taskdefs

Class WaitFor

Implemented Interfaces:
Cloneable, DynamicElement

public class WaitFor
extends ConditionBase

Wait for an external event to occur. Wait for an external process to start or to complete some task. This is useful with the parallel task to synchronize the execution of tests with server startup. The following attributes can be specified on a waitfor task: The maxwaitunit and checkeveryunit are allowed to have the following values: millisecond, second, minute, hour, day and week. The default is millisecond. For programmatic use/subclassing, there are two methods that may be overrridden, processSuccess and processTimeout
Since:
Ant 1.5

Nested Class Summary

static class
WaitFor.Unit
The enumeration of units: millisecond, second, minute, hour, day, week

Field Summary

Fields inherited from class org.apache.tools.ant.ProjectComponent

description, location, project

Constructor Summary

WaitFor()
Constructor, names this task "waitfor".

Method Summary

void
execute()
Check repeatedly for the specified conditions until they become true or the timeout expires.
protected void
processSuccess()
Actions to be taken on a successful waitfor.
protected void
processTimeout()
Actions to be taken on an unsuccessful wait.
void
setCheckEvery(long time)
Set the time between each check
void
setCheckEveryUnit(WaitFor.Unit unit)
Set the check every time unit
void
setMaxWait(long time)
Set the maximum length of time to wait.
void
setMaxWaitUnit(WaitFor.Unit unit)
Set the max wait time unit
void
setTimeoutProperty(String p)
Name the property to set after a timeout.

Methods inherited from class org.apache.tools.ant.taskdefs.condition.ConditionBase

add, addAnd, addAvailable, addChecksum, addContains, addEquals, addFilesMatch, addHttp, addIsFalse, addIsFileSelected, addIsReference, addIsSet, addIsTrue, addNot, addOr, addOs, addSocket, addUptodate, countConditions, createDynamicElement, getConditions, getTaskName, setTaskName

Methods inherited from class org.apache.tools.ant.ProjectComponent

clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject

Constructor Details

WaitFor

public WaitFor()
Constructor, names this task "waitfor".

Method Details

execute

public void execute()
            throws BuildException
Check repeatedly for the specified conditions until they become true or the timeout expires.
Throws:
BuildException - on error

processSuccess

protected void processSuccess()
Actions to be taken on a successful waitfor. This is an override point. The base implementation does nothing.
Since:
Ant1.7

processTimeout

protected void processTimeout()
Actions to be taken on an unsuccessful wait. This is an override point. It is where the timeout processing takes place. The base implementation sets the timeoutproperty if there was a timeout and the property was defined.
Since:
Ant1.7

setCheckEvery

public void setCheckEvery(long time)
Set the time between each check
Parameters:
time - a long value

setCheckEveryUnit

public void setCheckEveryUnit(WaitFor.Unit unit)
Set the check every time unit
Parameters:
unit - an enumerated Unit value

setMaxWait

public void setMaxWait(long time)
Set the maximum length of time to wait.
Parameters:
time - a long value

setMaxWaitUnit

public void setMaxWaitUnit(WaitFor.Unit unit)
Set the max wait time unit
Parameters:
unit - an enumerated Unit value

setTimeoutProperty

public void setTimeoutProperty(String p)
Name the property to set after a timeout.
Parameters:
p - the property name