ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: DynamicConfigurator question
Date Wed, 04 Sep 2002 16:44:13 GMT
With DynaConf, you're on your own, and need to keep track of what you create
yourself. And yes, setDynamicAttribute is only called on the for the
element, not it's sub-element.

I used DynaConf to build a DOM DocumentFragment, so every DOM Node was
created using createDynamicElement, which returned a wrapper (to the DOM
Node) implementing DynaConf again, and so on recursively.

So when createDynamicElement is called on your class, you store the created
element yourself in a Vector.

Hope this helps. --DD

-----Original Message-----
From: Shackelford, John-Mason [] 
Sent: Wednesday, September 04, 2002 11:00 AM
To: Ant Developers List
Subject: DynamicConfigurator question

I must be a little slow...

I use public Object createDynamicElement(String name) to instantiate an
object corresponding to a subelement. Ant calls this method and, using
introspection, it calls setters on the returned object where they correspond
to tag attributes in the build file.

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? 

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. 

I am trying to build a top level controller that processes and issues
commands. The commands are specified as subelements. They are responsible
for configuring themselves based on the attributes specified and then
handing over a very succinct bit of info that the controller can then

<controller arg1="">
	<someCommand someArg1="" someArg2=""/>
	<someOtherCommand someOtherArg=""/>

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. 

<controller arg1="">
	<command name="someCommand" someArg1="" someArg2=""/>
	<command name="someOtherCommand" someOtherArg=""/>

Though I suppose I could just use an abstract factory and have the
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).

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.

Thanks for holding my hand,

John-Mason Shackelford

Software Developer
NCS Pearson - Measurement Services
2510 North Dodge St.
Iowa City, IA 52245


This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 

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

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

View raw message