net.sf.antcontrib.process

Class Limit

public class Limit extends Task implements TaskContainer

Limits the amount of time that a task or set of tasks can run. This is useful for tasks that may "hang" or otherwise not complete in a timely fashion. This task is done when either the maxwait time has expired or all nested tasks are complete, whichever is first.

Developed for use with Antelope, migrated to ant-contrib Oct 2003.

Since: Ant 1.5

Version: $Revision: 1.6 $

Author: Dale Anson Robert D. Rice

Nested Class Summary
static classLimit.TimeUnit
The enumeration of units: millisecond, second, minute, hour, day, week Todo: we use timestamps in many places, why not factor this out
Field Summary
protected Limit.TimeUnitunit
Method Summary
voidaddTask(Task task)
Add a task to wait on.
voidexecute()
Execute all nested tasks, but stopping execution of nested tasks after maxwait or when all tasks are done, whichever is first.
voidsetDays(int value)
Set a day wait value.
voidsetFailonerror(boolean fail)
Determines whether the build should fail if the time limit has expired on this task.
voidsetHours(int value)
Set an hours wait value.
voidsetMaxwait(int wait)
How long to wait for all nested tasks to complete, in units.
voidsetMaxWaitUnit(Limit.TimeUnit unit)
Set the max wait time unit, default is minutes.
voidsetMilliseconds(int value)
Set a millisecond wait value.
voidsetMinutes(int value)
Set a minute wait value.
voidsetProperty(String p)
Name the property to set after a timeout.
voidsetSeconds(int value)
Set a second wait value.
voidsetUnit(String unit)
Sets the unit for the max wait.
voidsetValue(String v)
The value for the property to set after a timeout, defaults to true.
voidsetWeeks(int value)
Set a week wait value.

Field Detail

unit

protected Limit.TimeUnit unit

Method Detail

addTask

public void addTask(Task task)
Add a task to wait on.

Parameters: task A task to execute

Throws: BuildException won't happen

execute

public void execute()
Execute all nested tasks, but stopping execution of nested tasks after maxwait or when all tasks are done, whichever is first.

Throws: BuildException Description of the Exception

setDays

public void setDays(int value)
Set a day wait value.

Parameters: value the number of days to wait.

setFailonerror

public void setFailonerror(boolean fail)
Determines whether the build should fail if the time limit has expired on this task. Default is no.

Parameters: fail if true, fail the build if the time limit has been reached.

setHours

public void setHours(int value)
Set an hours wait value.

Parameters: value the number of hours to wait.

setMaxwait

public void setMaxwait(int wait)
How long to wait for all nested tasks to complete, in units. Default is to wait 3 minutes.

Parameters: wait time to wait, set to 0 to wait forever.

setMaxWaitUnit

public void setMaxWaitUnit(Limit.TimeUnit unit)
Set the max wait time unit, default is minutes.

setMilliseconds

public void setMilliseconds(int value)
Set a millisecond wait value.

Parameters: value the number of milliseconds to wait.

setMinutes

public void setMinutes(int value)
Set a minute wait value.

Parameters: value the number of milliseconds to wait.

setProperty

public void setProperty(String p)
Name the property to set after a timeout.

Parameters: p of property to set if the time limit has been reached.

setSeconds

public void setSeconds(int value)
Set a second wait value.

Parameters: value the number of seconds to wait.

setUnit

public void setUnit(String unit)
Sets the unit for the max wait. Default is minutes.

Parameters: unit valid values are "millisecond", "second", "minute", "hour", "day", and "week".

setValue

public void setValue(String v)
The value for the property to set after a timeout, defaults to true.

Parameters: v for the property to set if the time limit has been reached.

setWeeks

public void setWeeks(int value)
Set a week wait value.

Parameters: value the number of weeks to wait.