ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: DynamicConfigurator question
Date Wed, 04 Sep 2002 16:47:37 GMT
Shackelford, John-Mason wrote:

> Now that the subelement object has been populated, my class that implements
> DynamicConfigurator needs to call a method on the subelement object.
> Typically I would have an addXXX method and the subelements would be added
> to a Vector, but since XXX corresponds to an element name unknown to me at
> compile time, what do I do? 

When using the createXXX methods, including the DynamicConfigurator one, 
you don't get a chance to call methods on the populated objects until 
execute().  This is just how it is, and how all core Ant tasks operate.

Design your implementation to account for this and all will be well.

> I assume that the setDynamicAttribure method applies only to attributes of
> the tag associated with the DynamicConfigurator, not its subelements. So its
> not going to help. 

Your subelements could also implement DynamicConfigurator, and their 
subelements, and so on.  So, yes, it would help if you need to do super 
nested dynamic stuff.

> <controller>	I know I could achieve this by simply doing this and using
> DynamicConfigurator with dynamic attributes for subelements, but this could
> really make a mess since it would force one object to handle logic for lots
> of commands. 

You got a better design?

You're really going way out of the norm here for implementing Ant tasks, 
so either your on the bleeding edge or your out in left field!  :)

> DynamicConfigurator subelement just delegate all the work to an assortment
> of other classes that were mapped to the command name via a property file
> (thanks again Erik and Dominique for that insight).

Again, this has to do with plain old Java patterns and design.  How you 
do it is up to you, and your hands are not really tied that much with 
Ant - its not the bottleneck here, I don't think.  You've got 
ultra-dynamic capability.

> Okay, now I am wavering. Should I abandon my initial approach or am I
> missing something that would make it easy to do? It does seem somewhat
> friendlier to the end user to ask them to type: <myCommand arg=""/> instead
> of <command name="myCommand" arg=""/> but perhaps it isn't doable.

I can't say.  It is doable what you're asking for, but it sounds like 
you got much more going on than I can see or have time to digest.  Its 
up to you to design it to work the way you want, but Ant gives you the 
capabilities.  I've not seen a case you've presented where Ant was 
preventing you from doing something you wanted.


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

View raw message