ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <DDevie...@lgc.com>
Subject RE: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
Date Mon, 21 Feb 2005 15:30:30 GMT
> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@apache.org]
> 
> On 18 Feb 2005, <stevel@apache.org> wrote:
> 
> >   I'm tempted to retrofit Task.bindToOwner back to the 1.6.x
> >   codebase, for the benefit of third party tasks; same for the extra
> >   constructors for exec and java. Thoughts?
> 
> If you only port bindToOwner and the new constructors, but not all the
> points of invocation then you can't do much harm.

FWIW, just one nit about bindToOwner(), but a bit late since I saw the
commit like everyone else.

I would have reversed Steve's bindee.bindToOwner(owner) logic into
owner.configureHelper(helper), which then allows configureHelper to be
protected. It's basically the same, but avoids the public method which
then anyone can call on any task, and it's closer to the code I posted a
few times, and that I'll post again below.

Note also that my code init()s the helper task too, and that I was
always calling configureTask() in the parent task own init(). --DD

    /**
     * Configures a helper task to be used within another task.
     *
     * @param  parent the parent (custom) task using the helper task.
     * @param  helper the helper task to configure for use.
     * @return the configured helper task for call chaining.
     */
    public static Task configureTask(Task parent, Task helper) {
        // Make helper share attributes of the parent
        helper.setProject(parent.getProject());
        helper.setTaskName(parent.getTaskName());
        helper.setOwningTarget(parent.getOwningTarget());

        // Copy location for better troubleshooting of subtask
        Location location = parent.getLocation();
        if (location == null) {
            location = Location.UNKNOWN_LOCATION;
        }
        helper.setLocation(location);

        // Initialize (and return) the helper
        helper.init();
        return helper;
    }


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


Mime
View raw message