ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject RE: Wildcards in the file attribute for the available task
Date Wed, 10 Jul 2002 23:29:12 GMT
I couldn't think of any way to do it other than using <script>, along with
<parallel> and <waitfor>. (Well, I suppose you could 86 the <parallel> and
<waitfor> and just have the script do the timeout, but it gave me a good
excuse to play with them, and besides, it's less script code this way).

  <target name="waitforit">
    <property name="msgdir" location="jbossmq"/>
    <parallel>
      <waitfor maxwait="10" maxwaitunit="second" timeoutproperty="stuck">
        <isset property="all.gone"/>
      </waitfor>
      <script language="javascript"> <![CDATA[
        dir = new java.io.File(project.getProperty("msgdir")) ;
        for( ;; ) {
          if( dir.list().length == 0 ) {
            project.setNewProperty("all.gone", "true");
            break;
          } else {
            if( project.getProperty("stuck") != null ) { break ; }
          }
          java.lang.Thread.sleep(5000); // give it a rest :)
        }
        ]]>
      </script>
    </parallel>
    <fail unless="all.gone" message="Messages are stuck in the queue!"/>
    <echo>All gone!</echo>
  </target>

Of course, you'll want to up your "maxwaitunit" -- I just didn't feel like
sitting around for 10 minutes waiting to see if it worked :)

Also, it does rely on the idea that no files other than queued message
files live in that directory -- if that's not really guaranteed, you'll
need to beef it up to list only the pertinent files.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message