ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <>
Subject RE: cvs commit: jakarta-ant/proposal/myrmidon/src/manifest ant1-ant-descriptor.xml
Date Sun, 20 Jan 2002 01:10:22 GMT

> -----Original Message-----
> From: []
> Sent: Saturday, 19 January 2002 5:26 PM
> To:
> Subject: cvs commit: jakarta-ant/proposal/myrmidon/src/manifest
> ant1-ant-descriptor.xml

>   1.1
> jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/
> converters/

>       /**
>        * Converts from String to Path
>        *
>        * @param original the original Object
>        * @param context the context in which to convert
>        * @return the converted object
>        * @exception Exception if an error occurs
>        */
>       protected Object convert( Object original, Context context )
>           throws ConverterException
>       {
>           /*
>           String path = (String)original;
>           TaskContext taskContext = (TaskContext)context;
>           Path retval = new Path( path );
>           retval.setBaseDirectory( taskContext.getBaseDirectory() );
>           return retval;
>           */
>           return null;
>       }
>   }

Ah yes.  I just chucked this in here to get <path> working, and was trying
to ignore the problem of delivering context to data types.

Now I'm trying to get <fileset> and friends working, and it just ain't going
to happen without a general way to get context to the data types ("context"
here means whatever the data type needs to evaluate itself - Logger,
TaskContext, maybe other things).

As far as I can tell, there are 2 approaches we can take:

* Immediately prior to configuring an object, check whether it is
LogEnabled, Composable (maybe), Contextualizable, etc and set the Logger,
Context, etc there.  This may happen in the configurer, or maybe the type
factory.  Either way, it happens before the setX() method is called to pass
the object to its client task/type.

* Pass a TaskContext into the evaluate methods of the data type.  E.g.

public interface Path {
    String[] list( TaskContext context ) throws TaskException;

Ant 1 uses both methods:

Method 1: Anything that extends ProjectComponent gets contextualised during
configuration via setProject( Project ).

Method 2: Things like FileSet.getDirectoryScanner( Project ) and
Path.Path( Project ).

It would be a good thing to pick one of these methods, and apply it
consistently.  Any preference?

I'm leaning sligthly towards method 1, mainly because data types are handed
to the client task/type ready-to-use.  The down-side is that data types are
a little more involved to create programmatically, because the creator is
responsible for contextualising the data type before configuring and using
it (but that's what factory methods are for).  The client task/type also
loses control over the context that the data type uses to evaluate itself.
Personally, I prefer ease-of-use over infinite flexibility.


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message