org.apache.tools.ant.taskdefs

Class WaitFor

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

UNKNOWN: category="control"

Nested Class Summary
static classWaitFor.Unit
The enumeration of units: millisecond, second, minute, hour, day, week
Field Summary
static longDEFAULT_CHECK_MILLIS
default check time
static longDEFAULT_MAX_WAIT_MILLIS
default wait time
static longONE_DAY
a day in milliseconds
static longONE_HOUR
an hour in milliseconds
static longONE_MILLISECOND
a millisecond
static longONE_MINUTE
a minute in milliseconds
static longONE_SECOND
a second in milliseconds
static longONE_WEEK
a week in milliseconds
Constructor Summary
WaitFor()
Constructor, names this task "waitfor".
WaitFor(String taskName)
Constructor that takes the name of the task in the task name.
Method Summary
longcalculateCheckEveryMillis()
Get the check wait time, in milliseconds.
longcalculateMaxWaitMillis()
Get the maxiumum wait time, in milliseconds.
voidexecute()
Check repeatedly for the specified conditions until they become true or the timeout expires.
protected voidprocessSuccess()
Actions to be taken on a successful waitfor.
protected voidprocessTimeout()
Actions to be taken on an unsuccessful wait.
voidsetCheckEvery(long time)
Set the time between each check
voidsetCheckEveryUnit(WaitFor.Unit unit)
Set the check every time unit
voidsetMaxWait(long time)
Set the maximum length of time to wait.
voidsetMaxWaitUnit(WaitFor.Unit unit)
Set the max wait time unit
voidsetTimeoutProperty(String p)
Name the property to set after a timeout.

Field Detail

DEFAULT_CHECK_MILLIS

public static final long DEFAULT_CHECK_MILLIS
default check time

DEFAULT_MAX_WAIT_MILLIS

public static final long DEFAULT_MAX_WAIT_MILLIS
default wait time

ONE_DAY

public static final long ONE_DAY
a day in milliseconds

ONE_HOUR

public static final long ONE_HOUR
an hour in milliseconds

ONE_MILLISECOND

public static final long ONE_MILLISECOND
a millisecond

ONE_MINUTE

public static final long ONE_MINUTE
a minute in milliseconds

ONE_SECOND

public static final long ONE_SECOND
a second in milliseconds

ONE_WEEK

public static final long ONE_WEEK
a week in milliseconds

Constructor Detail

WaitFor

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

WaitFor

public WaitFor(String taskName)
Constructor that takes the name of the task in the task name.

Parameters: taskName the name of the task.

Since: Ant 1.8

Method Detail

calculateCheckEveryMillis

public long calculateCheckEveryMillis()
Get the check wait time, in milliseconds.

Returns: how long to wait between checks

Since: Ant 1.8

calculateMaxWaitMillis

public long calculateMaxWaitMillis()
Get the maxiumum wait time, in milliseconds.

Returns: how long to wait before timing out

Since: Ant 1.8

execute

public void execute()
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