ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <levylamb...@tiscali-dsl.de>
Subject Re: patch for namespaced antlib
Date Wed, 04 Jun 2003 09:48:56 GMT
Peter,

thanks for your work.

Your explanations concerning the scope of different flavours of typedef
declarations are important, make sure that they make their way in the
documentation.

Antoine

----- Original Message -----
From: "peter reilly" <peter.reilly@corvil.com>
To: <dev@ant.apache.org>
Sent: Wednesday, June 04, 2003 11:43 AM

.....
No,  adaptto is not a role, it is only used in association with
"adapter" - the adapter class gets used if the defined class does
not fullfill the contract specified by "adaptto". The idea is to
allow <taskdef classname="org.acme.MySuperTask ... /> to be implemented by
<typedef adapter="o.a.t.a.TaskAdapter" adaptto="o.a.t.a.Task"
classname="org.acme.MySuperTask" ....>
If mySuperTask does not extend Task, then the TaskAdapter will be used
to adapt MySuperTask.

The idea behind "role" is to restrict the definition to only be used
for the "add(Class)" methods and for "ant-type=" polymorphic attribute.
This is to allow the conditions/filters etc to be defined without polluting
the namespace. The definitions will only be active in the
add(Class)/ant-type
context.

To give a example: (and to use one of Jose's examples)
Say one has a ton of classes that use the method "isValid()" to
assert that the object is correct and one wants to use these
as conditions in ant.

One can write an adapter class that implements
 o.a.t.a.taskdefs.condition.Condition and adapts the isValid()
method to eval().  - org.acme.ValidConditionAdapter.

case 1:
<typedef adapter="org.acme.ValidConditionAdapter"
              classname="Class1" name="def1"/>

This will unconditionally adapt Class1 to a condition using
org.acme.ValidConditionAdapter even if Class1 implements
Condition.

The definition of "def1" may be used outside the context
of "add()". When used with add(o.a.t.a.taskdefs.c.Condition x),
the x.getClass() is org.acme.ValidConditionAdapter.

case 2:
<typedef adapter="org.acme.ValidConditionAdapter"
              adaptto="org.apache.tools.ant.taskdefs.condition.Condition"
              classname="Class1" name="def1"/>
This adapts Class1 to a condition using
org.acme.ValidConditionAdapter unless Class1 implements Condition.

The definition of "def1" may be used outside the context
of "add()". When used with add(o.a.t.a.taskdefs.c.Condition x),
the x.getClass() is org.acme.ValidConditionAdapter if Class1
does not implement Condition and Class1 if it does implement
condition.

case 3:
<typedef adapter="org.acme.ValidConditionAdapter"
              role="org.apache.tools.ant.taskdefs.condition.Condition"
              classname="Class1" name="def1"/>

This will unconditionally adapt Class1 to a condition using
org.acme.ValidConditionAdapter even if Class1 implements
Condition.

The definition of "def1" WILL ONLY be used in the context
of add(Condition x) and for ant-type="def1" polymorhic.
When used with add(o.a.t.a.taskdefs.c.Condition x),
the x.getClass() is org.acme.ValidConditionAdapter.
One may have a number of definitions of "def1" for different
roles.

case 4:
<typedef adapter="org.acme.ValidConditionAdapter"
              adaptto="org.apache.tools.ant.taskdefs.condition.Condition"
              role="org.apache.tools.ant.taskdefs.condition.Condition"
              classname="Class1" name="def1"/>

This will adapt Class1 to a condition using
org.acme.ValidConditionAdapter even if Class1 implements
Condition.

The definition of "def1" WILL ONLY be used in the context
of add(Condition x) and for ant-type="def1" polymorhic.
When used with add(o.a.t.a.taskdefs.c.Condition x),
the x.getClass() is org.acme.ValidConditionAdapter if
Class1 does not implement Condition and Class1 if
it does.
One may have a number of definitions of "def1" for different
roles.





Mime
View raw message