Package org.apache.tools.ant.taskdefs
Class WaitFor
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.taskdefs.condition.ConditionBase
org.apache.tools.ant.taskdefs.WaitFor
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BlockFor
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:
- maxwait - maximum length of time to wait before giving up
- maxwaitunit - The unit to be used to interpret maxwait attribute
- checkevery - amount of time to sleep between each check
- checkeveryunit - The unit to be used to interpret checkevery attribute
- timeoutproperty - name of a property to set if maxwait has been exceeded.
processSuccess
and processTimeout
- Since:
- Ant 1.5
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The enumeration of units: millisecond, second, minute, hour, day, week -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
default check timestatic final long
default wait timestatic final long
a day in millisecondsstatic final long
an hour in millisecondsstatic final long
a millisecondstatic final long
a minute in millisecondsstatic final long
a second in millisecondsstatic final long
a week in millisecondsFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Get the check wait time, in milliseconds.long
Get the maximum wait time, in milliseconds.void
execute()
Check repeatedly for the specified conditions until they become true or the timeout expires.protected void
Actions to be taken on a successful waitfor.protected void
Actions to be taken on an unsuccessful wait.void
setCheckEvery
(long time) Set the time between each checkvoid
Set the check every time unitvoid
setMaxWait
(long time) Set the maximum length of time to wait.void
setMaxWaitUnit
(WaitFor.Unit unit) Set the max wait time unitvoid
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, getConditions, getTaskName, setTaskName
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
-
Field Details
-
ONE_MILLISECOND
public static final long ONE_MILLISECONDa millisecond- See Also:
-
ONE_SECOND
public static final long ONE_SECONDa second in milliseconds- See Also:
-
ONE_MINUTE
public static final long ONE_MINUTEa minute in milliseconds- See Also:
-
ONE_HOUR
public static final long ONE_HOURan hour in milliseconds- See Also:
-
ONE_DAY
public static final long ONE_DAYa day in milliseconds- See Also:
-
ONE_WEEK
public static final long ONE_WEEKa week in milliseconds- See Also:
-
DEFAULT_MAX_WAIT_MILLIS
public static final long DEFAULT_MAX_WAIT_MILLISdefault wait time- See Also:
-
DEFAULT_CHECK_MILLIS
public static final long DEFAULT_CHECK_MILLISdefault check time- See Also:
-
-
Constructor Details
-
WaitFor
public WaitFor()Constructor, names this task "waitfor". -
WaitFor
Constructor that takes the name of the task in the task name.- Parameters:
taskName
- the name of the task.- Since:
- Ant 1.8
-
-
Method Details
-
setMaxWait
public void setMaxWait(long time) Set the maximum length of time to wait.- Parameters:
time
- along
value
-
setMaxWaitUnit
Set the max wait time unit- Parameters:
unit
- an enumeratedUnit
value
-
setCheckEvery
public void setCheckEvery(long time) Set the time between each check- Parameters:
time
- along
value
-
setCheckEveryUnit
Set the check every time unit- Parameters:
unit
- an enumeratedUnit
value
-
setTimeoutProperty
Name the property to set after a timeout.- Parameters:
p
- the property name
-
execute
Check repeatedly for the specified conditions until they become true or the timeout expires.- Throws:
BuildException
- on error
-
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 maximum wait time, in milliseconds.- Returns:
- how long to wait before timing out
- Since:
- Ant 1.8
-
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
-