ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Feller" <>
Subject Re: can I subclass Condition to create my own conditions for "waitfor" task?
Date Sat, 20 Sep 2003 10:54:29 GMT

You have to subclass ConditionBase and override the eval()

This method is called by the execute so your condition will
be available into condition block with standard mecanism.

Hope it helps,

----- Message d'origine -----
De : "Alan Bram" <>
À : <>
Envoyé : samedi 20 septembre 2003 00:06
Objet : can I subclass Condition to create my own conditions
for "waitfor" task?


I've written an Ant task that I will use in running unit
tests (under CruiseControl).  The task waits for my JBoss
server to complete its start-up process.  It works via
access to the JBoss JMX MBean for the Main Deployer, so that
I know it's really ready before I start my tests.

I've patterned my code after the Ant "waitfor" task, in
terms of allowing the user to specify frequency and time
limit, both value and units independently, because I think
that's pretty cool.  (I hate having to guess whether a time
was specified in milliseconds, or seconds, or whatever.)

However, I suddenly realized that instead of making my code
*like* Ant's "waitfor" task, it would be really cool if I
could actually re-use it.  It seemed like I almost could, if
only I could make up my own Condition (i.e.,  The
ConditionBase class (which is the base class of WaitFor)
knows about only a fixed set of types of Condition's.  It
seemed like I could almost add my own if I subclassed
WaitFor, by adding my own addMyCondition() method.  But it
looks like that won't quite work, because ConditionBase
keeps its "conditions" field private.

Does anyone see a good way to make this work?

I suppose maybe I could just override the getConditions()
method to ignore all other Condition's and just return my
Condition.  But that seems a bit ugly?

I thank you in advance for any thoughts on this matter.

 - Alan Bram

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message