ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <>
Subject RE: [myrmidon] declaring roles in typelibs
Date Thu, 31 Jan 2002 06:26:40 GMT

> -----Original Message-----
> From: Peter Donald []
> Sent: Wednesday, 30 January 2002 7:12 PM
> To: Ant Developers List
> Subject: Re: [myrmidon] declaring roles in typelibs
> Hi,
> On Wed, 30 Jan 2002 00:15, Adam Murdoch wrote:
> > I'm looking at how we might allow typelibs to declare custom roles.  The
> > reason is so that types/tasks in a typelib can use the new
> > add(RoleInterface) configuration methods, for roles declared in the
> > typelib.
> How do you intend to solve the ClassLoader problem - namely can a 
> role only 
> be used by types in the same type library?

ClassNotFoundException :)

For the time being, there's a work-around - rename your typelib to .jar and drop it into lib/.

Longer term, we could do a few things:

* Allow a typelib to declare itself 'public', so that its classes are visible to all the other

* Or, allow a typelib to declare its dependencies.  Either in the descriptor, or in the manifest.
 The dependencies would be made visible to the typelib (except that multi-parent classloaders
might be asking for trouble?).

* Plus a bunch of other things, no doubt.

> > * DefaultDeployer adds the roles from a typelib, on the first 
> import from a
> > typelib.  This would happen for the first of any of the 
> deployX( ) methods.
> Something "smells" about this but I can't put my finger on it ;)

I agree.  Just something to get things working.

I suspect the need for the distinction between roles and types could go away if we introduce
a type heirarchy - roles are just higher up the type hierarchy.  Just a thought.

> > * Change AbstractTypeDef and ConverterDef to use the Deployer to add
> > converters and types.
> +1
> As long as they can still construct their own ClassLoaders and explicitly 
> pass in their own registrations. ie If Want to compile atask and 
> then can't 
> bothered to create an antlib I still want to be able to taskdef it?

Absolutely.  Deployer now allows you to deploy from either a ClassLoader, or a File.  They
may, but don't have to, contain role descriptors, or type descriptors, or both.  There's a
bunch of new deployX() methods, so you can:

* Deploy everything in the typelib.
* Deploy a single type by role/name.  Similar for a converter.
* Deploy a single type or converter, by explicitly supplying all required info.

What I'd like to do later is add config beans for type, converter and role definitions, so
that the DefaultDeployer (or a def task for that matter) can build them by introspection.
 And so we can add stuff to the declarations, without having to change the deployer or the
def tasks.

> > * Add TypeManager.registerType( Class roleInterface, String typeName,
> > TypeFactory factory ), to avoid the type manager having to deal with
> > classloaders to find the role interface.
> +0.5 Though something feels a bit icky about this too ;) I think 
> I just have 
> an extreme allergy to passing around Class objects after being 
> burned several 
> times in the past after doing so ;)

Fair enough.

Another option is to get rid of the check in MultiSourceTypeFactory that makes sure that the
instantiated object is an instance of the role interface.

Or we could register the role interface Class object somewhere, so that MultiSourceTypeFactory
can find it without needing to know which ClassLoader to use.


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

View raw message