ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Hennessy" <de...@network365.com>
Subject RE: [SUBMIT] Waitfor task
Date Thu, 29 Nov 2001 03:05:36 GMT
This is the <waitfor> task reworked as Stefan suggested to use the same
condition elements as the <condition> task. I've also changed the
<socket> and <http> conditions to work in the same way so that they're
also available as generic conditions. The original <file> test is now
gone and replaced by the existing <available> condition.

Could someone please review for submission? Here's where the files go:

WaitFor.java: ./src/main/org/apache/tools/ant/taskdefs/WaitFor.java
Http.java: ./src/main/org/apache/tools/ant/taskdefs/condition/Http.java
Socket.java:
./src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
Waitfor_html.txt: ./docs/manual/CoreTasks/waitfor.html
Waitfor.patch: applies patches to 
    ./docs/manual/coretasklist.html
    ./ocs/manual/CoreTasks/condition.html
    ./src/main/org/apache/tools/ant/taskdefs/defaults.properties
 
./src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java

Regards,
Denis

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@apache.org] 
> Sent: 28 November 2001 10:38
> To: ant-dev@jakarta.apache.org
> Subject: Re: [SUBMIT] Waitfor task
> 
> 
> On Wed, 28 Nov 2001, Denis Hennessy <denis@network365.com> wrote:
> 
> > The idea with waitfor is that there's a set of sub-elements that 
> > define the conditions you are waiting for.
> 
> Yet another idea - make that conditions implement Condition 
> and your task extend ConditionBase.
> 
> This way <condition> could check for the existance of 
> documents or whether something is listening on a given socket 
> - in turn, you could drop your <file> condition in favour of 
> <available> and gain access to <not> (don't know whether the 
> other built-in conditions would be useful as well).  This 
> would also make the ANDing of conditions you perform 
> explicit, which is a good thing IMHO.
> 
> Something like
> 
> <waitfor>
>   <not>
>     <socket ... />
>   </not>
> </waitfor>
> 
> which would test whether a server has been shutdown.
> 
> Basically <waitfor> really is a <condition> wrapped into a 
> loop that spins until the condition gets true, isn't it?
> 
> You'd have something like
> 
>     protected class WaitForCondition implements WaitForEvent {
>         boolean hasPassed = false;
>         Condition c = null;
> 
>         public void setCondition(Condition c) {
>             this.c = c;
>         }
> 
>         public boolean isReady() {
>             if (hasPassed) {
>                 return true;
>             }
>             if (c == null) {
>                 throw new BuildException("No condition specified");
>             }
> 
>             if (c.eval()) {
>                 hasPassed = true;
>                 return true;
>             } else {
>                 return false;
>             }
>         }
>     }
> 
> and would implement the logic inside the conditions instead 
> of the WaitForEvent implementations.
> 
> Stefan
> 
> --
> To unsubscribe, e-mail:   
> <mailto:ant-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:ant-dev-help@jakarta.apache.org>
> 

Mime
View raw message