cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <>
Subject classloader suggestion
Date Wed, 21 Feb 2001 21:48:28 GMT
here is a suggestion that Craig sent me privately.... can you guys take
care of this? thanks.

                             - o -

However, here's an algorithm that will work on any servlet container
that uses
URLClassLoader (as Tomcat 4.0 does):

* Get the classloader for the webapp:
    ClassLoader cl = this.getClass().getClassLoader()

* Cast it to URLClassLoader and call getURLs().

* Extract the paths from these URLs and add them to the classpath
  you are constructing.

* Call getParent() to get this class loader's parent classloader.

* If the parent classloader is also a URLClassLoader, repeat the
  previous three steps.

By the time this loop terminates, you will have all the JAR files and
that are visible to the web app, no matter how many class loaders are
involved and
no matter which class loader contains which particular JAR files.

Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<>                             Friedrich Nietzsche

View raw message