ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathan doklovic>
Subject ClasspathUtils with or vs. JavaResource
Date Wed, 16 Jan 2008 14:41:05 GMT

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 

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

View raw message