On Wednesday 17 September 2003 12:22, Stefan Bodewig wrote:
> On Wed, 17 Sep 2003, peter reilly <[EMAIL PROTECTED]> wrote:
>
>
> > I have done some more investigation.  The reason why using defined
> > definitions do not work unless antlib is an taskcontainer is
> > UnknownElement#handleChildren. This loops tru the all unknown
> > elements and checks if the parent can handle them. After
> > handleChildren is called, the maybeConfigure is called which invokes
> > the defines if addConfigured(AntlibInterface) is used in antLib.
>
> So you need to supress/delay the invocation?  I'm not sure I follow
> you, sorry.

Sorry my description was a little incoherent.

I wrote an Antlib with:

    public void addConfigured(AntlibInterface nestedTask) {
        System.out.println("Antlib: addConfigured");
        if (nestedTask instanceof Task) {
            setLocation(((Task) nestedTask).getLocation());
        }
        nestedTask.setURI(uri);
        nestedTask.setAntlibClassLoader(getClassLoader());
        if (nestedTask instanceof Task) {
            ((Task) nestedTask).perform();
        }
    }

and tested it with an antlib:

<antlib xmlns:c="ant:current">
  <presetdef name="define.with.echo">
    <typedef classtype="org.apache.tools.ant.taskdefs.Echo"/>
  </presetdef>
  <c:define.with.echo name="define.test"/>
</antlib>

The <c:define.with.echo> element gets rejected in 
UnknownElement#handleChildren() before
Antlib#addConfigured() is called for the <presetdef> element
of the antlib.

Peter

>
> > A fix could be to keep antlib being a task container, but check
> > if the type of task/type is a AntlibInterface, and if not, to
> > reject the task/type.
>
> I don't think so.  To me it seems that it should be possible for
> <antlib> to accept arbitrary AntlibInterface instances as children
> without resorting to TaskContainer.  If Antlib can't do that, it feels
> as if something was not right ATM.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to