ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <adammurdoch...@yahoo.com>
Subject RE: What is going on in ANT1.x
Date Wed, 06 Feb 2002 07:23:30 GMT

Hi,

This is the magic of UnknownElement, which extends Task, but can turn itself
into a data type.

Here's what happens:

1. When configuring the <sequential> element, a ProjectHelper.TaskHandler is
used to build its contents, because Sequential implements TaskContainer.

2. When the ProjectHelper.TaskHandler hits the nested <path> element, it
tries to create a "path" task.  That fails, so it assumes that the task will
be defined later, and creates an UnknownElement placeholder.

3. ProjectHelper.TaskHandler calls Sequential.addTask( ) with the
UnknownElement placeholder.  Since UnknownElement extends Task, this is
fine.  This is where the apparent type violation happens.

4. Later, when Sequential executes, it calls the UnknownElement's perform()
method, to execute it.

5. UnknownElement.perform() first attempts to create a "path" task.  When
that fails, it attempts to make a "path" data type.  That, of course, works.
And so the path gets created.

Of course, this is the simplified version of what happens.  There's some
very brittle stuff in there.  We would do far worse than to refactor the
project building code, and take the compatibility hit.


Adam

> -----Original Message-----
> From: Jose Alberto Fernandez [mailto:j_a_fernandez@yahoo.com]
> Sent: Wednesday, 6 February 2002 11:45 AM
> To: Ant Project List
> Subject: What is going on in ANT1.x
>
>
> Hi,
>
> I am puzzeled at how the current TaskContainer code works in
> ANT1.x and would like someone to explain it to me.
> Maybe I am missing something obvious.
>
> A task like <sequential/> only implements one method
> "addTask(Task)". However if I put inside a datatype declaration
> (which is not a Task) the operation succeeds. Now, this looks
> like a violation of all the typeing rules we have defined,
> which means we are cheating somewhere. Can omeone tell me where?
>
>     <sequential>
>         <path id='xxx'/>
>     </sequential>
>
> For this to work, I would have thought that TaskContainer needed
> a signature like "addTask(ProjectComponent)".
>
> Any hints on how this type violation was circumvented?
>
> Jose Alberto
>
>
>


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