You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/09/29 18:16:45 UTC

DO NOT REPLY [Bug 40643] New: - Allow dependency injection on child tasks

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40643>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40643

           Summary: Allow dependency injection on child tasks
           Product: Ant
           Version: 1.7.0Beta2
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: kgregory@healthmarketscience.com


Add the following method to the Task class, with no-op default behavior:

    /**
     *  Allows parent tasks to inject dependencies into their children.
     *  This method is typically called by the parent in <code>addTask()
     *  </code>. Children may accept or reject the dependency, and do
     *  not have to notify the parent.
     *
     *  @param  parent  Identifies the parent task.
     *  @param  data    Arbitrary dependency data. The child must know
     *                  how to process this data. May be <code>null</code>.
     */
    public void injectDependency(Task parent, Object data)

The implementation on UnknownElement would queue all (parent,data) tuples, then
play those back to the actual child in configure()

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40643] - Allow dependency injection on child tasks

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40643>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40643


gudnabrsam@yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From gudnabrsam@yahoo.com  2006-10-13 12:55 -------
could be interesting, but personally I'd need more detail, maybe a use case and
an example, to form a real opinion here.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 40643] - Allow dependency injection on child tasks

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40643>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40643





------- Additional Comments From kgregory@healthmarketscience.com  2006-10-16 16:22 -------
The current design of Ant assumes that child tasks are independent of their
parent: Ant calls the task's no-arg constructor, then adds it to the parent. It
does not tell the child about the parent (as best I can tell, looking closely at
the 1.6.5 codebase and skimming 1.7.0).

There are many situations where this knowledge would be useful, allowing the
parent to set up a context in which the child operations. For example, we have a
set of Ant tasks that interact with an app-server. They're contained within a
task that establishes the connection to the server, and provides context for the
children.

Similarly, one could envision a deployment target that executes multiple SQL
statements against a server. While you could create the connection anew for each
child task, a better approach (in my opinion) would look like the following:

<sqlConnect url="jdbc:..." user="${db.username} pass="${db.password}>
   <sqlUpdate sql="insert into ${db.schema}.MY_TABLE ...">

At present, it is possible to do this, but there are limitations.

One approach is to use nested elements, and have the parent task provide a
factory method for its children. The primary limitation to that approach is that
the children will be configured at the same time as the parent, meaning that you
have to deal with all properties as strings, and perform all conversions
yourself (because the properties may not have been set at the time of
configuration, particularly if they're set by sibling tasks).

Another approach is to use the "normal" method of task creation, and have the
parent reconfigure its children before executing them. This is somewhat of a
hack, as the parent has to dig into the UnknownElement to find the real task. It
also didn't work prior to bugfix #40641, because the UnknownElement would ignore
the parent's actions, and reconfigure the task prior to execution.

I am hoping to be able to free up the time to write a patch and some example
scripts.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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