ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle Adams" <kad...@gfs.com>
Subject Re: create or add subtask??
Date Wed, 05 Jun 2002 20:32:02 GMT
I've got further questions on this.  I'm currently modifying the XmlTask (http://www.oopsconsultancy.com/software/xmltask.html)
I found on the External Tools and Tasks page.

I'd like to make a decision in the addXXXX task based on the attributes of XXXX.  I'd hoped
that when Ant instantiated the object, it would call the object's setter methods to get those
attributes, but it appears that those attributes aren't set until Ant configures the object.
 Am I correct?  When will Ant configure the object?  When the parent element's execute method
is called?

Kyle

>>> conor@cortexebusiness.com.au 06/03/02 08:20AM >>>
Laval Chung wrote:
> For subtask we either create or add?
> What's the difference and when to use which?
> 
> Cheers
> laval
> 

When you use addXXX, Ant will instantiate the object, pass it to the add 
method and then configure it. For Ant to be able to instantiate the class it 
must support a Zero Argument Constructor (ZAC).

When you use createXXX, Ant will call createXXX and your task must create 
the sub-object and return it to Ant which will then configure it. As such 
your task can create the sub-object with whatever means available.

BTW, the above is the simple explanation :-).

In general, the preference nowadays is to use addXXX methods. These are more 
extensible since Ant can provide a subclass of the class required by the 
addXXX methods. That isn't much of an issue today but in the future such 
behaviour is envisaged.

Also, it is not strictly a sub-task - more a sub-element.

Conor



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



--
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