From costin@eng.sun.com Fri Feb 25 01:39:22 2000 Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 48617 invoked from network); 25 Feb 2000 01:39:22 -0000 Received: from adsl-63-198-47-229.dsl.snfc21.pacbell.net (HELO costin.dnt.ro) (63.198.47.229) by locus.apache.org with SMTP; 25 Feb 2000 01:39:22 -0000 Received: from localhost (costin [63.198.47.229]) by costin.dnt.ro (8.9.3+Sun/8.9.1) with ESMTP id RAA16390 for ; Thu, 24 Feb 2000 17:39:11 -0800 (PST) From: costin@eng.sun.com Date: Thu, 24 Feb 2000 17:40:17 -0800 (PST) To: ant-dev@jakarta.apache.org Subject: Re: Subtasks within tasks In-Reply-To: <1544879.3160411628@turtle.coral.cs.cmu.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I have few problems with that particular solution: - it is specific to Tasks ( createSubTask, SubTaskable, etc ) - everything else in ant is using introspection and patterns. - it sound a bit to complex - What is a sub task anyway ? I can't figure what it will do. SubCopy? If you have a particular task that needs this kind of sub-task we should try to find a pattern-based solution. In particular addXXX works fine in this case and doesn't require any interface ( and it's implemented in tomcat ): For "": - first try createFoo() - if no such method is found, try to create a foo object ( based on existing taskdefs ) - try addFoo( foo ) - if no such method try addBar() where Bar is an interface implemented by foo ( or superclass). Each "try" is just a getMethod() and check if not null, and it's very easy. I think the pattern makes sense and in tomcat seems to work fine ( addServerConnector() with AjpConnector, HttpConnector, etc ). Costin > The current ANT allows you to have properties within tasks, and these can > be arbitrarily nested, but each one requires a createXxxx() method to > return an object that goes along with that XML property. This means you > can't have general sub-Tasks. You'd have to make a createXxxx() method for > each task - not feasable. > > So, I've implemented some changes that allow arbirary sub-Tasks. There > is a new interface: SubTaskable which has an addSubTask(Task) method. When > a property is encountered for which there is no createXxxx() method, the > element is checked to see if it implements SubTaskable. If it does then a > task with the appropriate name is created and added using the > addSubTask(Task) method. > > To keep things clean I also modified Target and Task slightly. Target > now implements SubTaskable. The Task.setTarget(Target) has been changed to > Task.setTarget(SubTaskable). I also deprecated the Target.addTask(Task) > method. It does the same thing as the new addSubTask(Task) method. I > didn't use addTask(Task) in the SubTaskable interface because that might > conflict with an attribute. With it's two capitals, addSubTask() cannot. > > I've attached diffs for ProjectHelper.java, Task.java and Target.java. > I've attached the complete SubTaskable.java. I've also attached a task, > SubTaskTest.java, that simply executes each of its subtasks in order. > > later, > > \x/ill :-} >