ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <>
Subject Re: Roles (was: antlib)
Date Mon, 28 Apr 2003 16:28:53 GMT
I would agree nearly 100% with Costin.


There will be only one mapping defined elementtag -> java class.

 ------------------------ Introspection Mapping -----
This class will be used if there is no add[Configured]<ElementTag>()

The introspection mapping should be extended to handle

   4. public void add(NestedElement anInner)
   5. public void addConfigured(NestedElement anInner)

To adapt the ant manual:
The difference between 4 and 5 is what Ant has done to the object before it 
passes it to the method. add will receive an object directly after the 
constructor has been called, while addConfigured gets the object after the 
attributes and nested children for this new object have been handled.

------------------------ Matching rules -----

The matching rules will be the same as normal java rules for overloading.

public class Test {
    public static interface A {}
    public static interface B {}
    public static interface C extends A {}

    public static class Aimpl implements A{}
    public static class Bimpl implements B{}
    public static class Cimpl implements C{}
    public static class ABimpl implements A,B{}
    public void add(A a) {} // 1
    public void add(B b) {} // 2
    public void add(C b) {} // 3

An object of Cimpl gets method 3, An object of ABImpl is ambiguous and is 

------------------------ Tasks/Syntax -----
typedef and taskdef are left as at present and a new component task is added.

<component name="elementName" className=".." [adaptor =""]>
This is basicly the same as <typedef/> except:

   1) if the class extends Task, or  the adaptor extends Task, the component
       is treated in Ant as a Task.
   2) if there is an adaptor, this is the class the will be used in the
      add(Class x)
   3) if the class has "execute" without an adaptor, the component will
      not get TaskAdaptor. The reason for this is that if a class has an
      "execute" method, ant will make it a Task. This raises problems in which
      class to use for introspection purposes. The adaptor attribute makes
      this explicit.

------------------------ Example -----
Say there is a class with

public class MyTask extends Task {
   public void add(FileSet fileset) {       filesets.add(fileset);    }
   public void add(ZipFileSet ignore) {
        throw new BuildException("Not able to deal with zipped files");

one should expect the following to work:

   <typedef name="mytask" classname="MyTask"/>
    <!-- or <component name="mytask" classname="MyTask"/> -->
        <fileset dir="${classes}"/>
        <libfileset dir="${libdir}"/>

to work and 
     <mytask> <zipfileset dir="zipped"/> </mytask>
to throw the build exception


View raw message