jonathan doklovic wrote:
Hey,

I've been working on refactoring some code to make it easier to
implement relative resources in things like the import task.

After looking at BaseDef and AntLibDefinition, it seemed that it was a
bit backwards and AntlibDefinition should actually extend a base class
that provides basic classpath lookups.

In trying to do this refactoring, I realized that all of this stuff was
just using ClasspathUtils and not using JavaResource or
ClasspathResource so I figured the refactoring should include this
update as well.

However, after digging in, it seems to get very complex...
ClasspathUtils (and it's Delegate) does a lot of work to figure out the
classloader and reuse one if it can.  To do this, there's a bunch of
delegate calls that get made and eventually the calling task takes the
class loader returned by the delegate and loads the resource (unless
it's a file, then it just loads it).

With a ClasspathResource, you basically give it the path and the
resource name, and it does it's own simpler checks to figure out and
reuse the classloader and you can tell it to load the resource. However,
you cannot get a reference to the classloader used.

My question is, should these be used together?  It seems a little
overkill to do all the steps required in ClasspathUtils just to get the
path for the resource to then in turn pass it to a ClasspathResource
which is going to use it's own classloader anyway.

There's got to be a cleaner way to do this, i'm just not sure if
ClasspathUtils should be updated to return/use ClasspathResources, or if
the ClasspathResource should get a little smarter to bypass the utils
class alltogether.

any thoughts?

- Jonathan

the two goals of ant's classpath work are

(a) reuse stuff so that you can share data properly
(b) not leak like a leaky-sieve, and so cause IDEs or app servers to run out of memory

The classpath stuff does achieve both, but I'd have to look at all of this to see what is going on. You are clearly provoking us into a code review



--
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to