Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class WaitFor

extends ConditionBase
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.optional.testing.BlockFor
Imports
java.util.HashMap, .Locale, .Map, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.taskdefs.condition.Condition, .ConditionBase, org.apache.tools.ant.types.EnumeratedAttribute

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 overridden, processSuccess and processTimeout
Since
Ant 1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
WaitFor.Unit

The enumeration of units: millisecond, second, minute, hour, day, week

Field Summary

Modifier and TypeField and Description
private long
checkEvery

check time in the current unit

private long
public static final long
DEFAULT_CHECK_MILLIS

default check time

public static final long
DEFAULT_MAX_WAIT_MILLIS

default wait time

private long
maxWait

default max wait time in the current unit

private long
public static final long
ONE_DAY

a day in milliseconds

public static final long
ONE_HOUR

an hour in milliseconds

public static final long
ONE_MILLISECOND

a millisecond

public static final long
ONE_MINUTE

a minute in milliseconds

public static final long
ONE_SECOND

a second in milliseconds

public static final long
ONE_WEEK

a week in milliseconds

private String

Constructor Summary

AccessConstructor and Description
public
WaitFor()

Constructor, names this task "waitfor".

public
WaitFor(String
the name of the task.
taskName
)

Constructor that takes the name of the task in the task name.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

how long to wait between checks
calculateCheckEveryMillis
()

Get the check wait time, in milliseconds.

public long

Returns:

how long to wait before timing out
calculateMaxWaitMillis
()

Get the maximum wait time, in milliseconds.

public 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.

public void
setCheckEvery(long
a long value
time
)

Set the time between each check

public void
setCheckEveryUnit(WaitFor.Unit
an enumerated Unit value
unit
)

Set the check every time unit

public void
setMaxWait(long
a long value
time
)

Set the maximum length of time to wait.

public void
setMaxWaitUnit(WaitFor.Unit
an enumerated Unit value
unit
)

Set the max wait time unit

public void
setTimeoutProperty(String
the property name
p
)

Name the property to set after a timeout.

Inherited from org.apache.tools.ant.taskdefs.condition.ConditionBase:
addaddAndaddAvailableaddChecksumaddContainsaddEqualsaddFilesMatchaddHttpaddIsFalseaddIsFileSelectedaddIsReferenceaddIsSetaddIsTrueaddNotaddOraddOsaddSocketaddUptodatecountConditionsgetConditionsgetTaskNamesetTaskName

Field Detail

checkEveryback to summary
private long checkEvery

check time in the current unit

checkEveryMultiplierback to summary
private long checkEveryMultiplier
DEFAULT_CHECK_MILLISback to summary
public static final long DEFAULT_CHECK_MILLIS

default check time

DEFAULT_MAX_WAIT_MILLISback to summary
public static final long DEFAULT_MAX_WAIT_MILLIS

default wait time

maxWaitback to summary
private long maxWait

default max wait time in the current unit

maxWaitMultiplierback to summary
private long maxWaitMultiplier
ONE_DAYback to summary
public static final long ONE_DAY

a day in milliseconds

ONE_HOURback to summary
public static final long ONE_HOUR

an hour in milliseconds

ONE_MILLISECONDback to summary
public static final long ONE_MILLISECOND

a millisecond

ONE_MINUTEback to summary
public static final long ONE_MINUTE

a minute in milliseconds

ONE_SECONDback to summary
public static final long ONE_SECOND

a second in milliseconds

ONE_WEEKback to summary
public static final long ONE_WEEK

a week in milliseconds

timeoutPropertyback to summary
private String timeoutProperty

Constructor Detail

WaitForback to summary
public WaitFor()

Constructor, names this task "waitfor".

WaitForback to summary
public WaitFor(String taskName)

Constructor that takes the name of the task in the task name.

Parameters
taskName:String

the name of the task.

Since
Ant 1.8

Method Detail

calculateCheckEveryMillisback to summary
public long calculateCheckEveryMillis()

Get the check wait time, in milliseconds.

Returns:long

how long to wait between checks

Since
Ant 1.8
calculateMaxWaitMillisback to summary
public long calculateMaxWaitMillis()

Get the maximum wait time, in milliseconds.

Returns:long

how long to wait before timing out

Since
Ant 1.8
executeback to summary
public void execute() throws BuildException

Check repeatedly for the specified conditions until they become true or the timeout expires.

Exceptions
BuildException:
on error
processSuccessback to summary
protected void processSuccess()

Actions to be taken on a successful waitfor. This is an override point. The base implementation does nothing.

Since
Ant1.7
processTimeoutback to summary
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
setCheckEveryback to summary
public void setCheckEvery(long time)

Set the time between each check

Parameters
time:long

a long value

setCheckEveryUnitback to summary
public void setCheckEveryUnit(WaitFor.Unit unit)

Set the check every time unit

Parameters
unit:WaitFor.Unit

an enumerated Unit value

setMaxWaitback to summary
public void setMaxWait(long time)

Set the maximum length of time to wait.

Parameters
time:long

a long value

setMaxWaitUnitback to summary
public void setMaxWaitUnit(WaitFor.Unit unit)

Set the max wait time unit

Parameters
unit:WaitFor.Unit

an enumerated Unit value

setTimeoutPropertyback to summary
public void setTimeoutProperty(String p)

Name the property to set after a timeout.

Parameters
p:String

the property name

org.apache.tools.ant.taskdefs back to summary

public Class WaitFor.Unit

extends EnumeratedAttribute
Class Inheritance

The enumeration of units: millisecond, second, minute, hour, day, week

Field Summary

Modifier and TypeField and Description
public static final String
DAY

day string

public static final String
HOUR

hour string

public static final String
MILLISECOND

millisecond string

public static final String
MINUTE

minute string

public static final String
SECOND

second string

private Map<String, Long>
private static final String[]
public static final String
WEEK

week string

Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public
Unit()

Constructor the Unit enumerated type.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

a multiplier (a long value)
getMultiplier
()

Convert the value to a multiplier (millisecond to unit).

public String[]
getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

This is the only method a subclass needs to implement.
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Field Detail

DAYback to summary
public static final String DAY

day string

HOURback to summary
public static final String HOUR

hour string

MILLISECONDback to summary
public static final String MILLISECOND

millisecond string

MINUTEback to summary
public static final String MINUTE

minute string

SECONDback to summary
public static final String SECOND

second string

timeTableback to summary
private Map<String, Long> timeTable
UNITSback to summary
private static final String[] UNITS
WEEKback to summary
public static final String WEEK

week string

Constructor Detail

Unitback to summary
public Unit()

Constructor the Unit enumerated type.

Method Detail

getMultiplierback to summary
public long getMultiplier()

Convert the value to a multiplier (millisecond to unit).

Returns:long

a multiplier (a long value)

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Doc from org.apache.tools.ant.types.EnumeratedAttribute.getValues.

This is the only method a subclass needs to implement.

Returns:String[]

an array holding all possible values of the enumeration. The order of elements must be fixed so that indexOfValue(String) always return the same index for the same value.

Annotations
@Override
See Also
EnumeratedAttribute#getValues()