You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/07/12 23:22:36 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java

remm        01/07/12 14:22:32

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappClassLoader.java
  Log:
  - The addRepository call will now add the specified repository (if it's a valid URL)
    to the superclass (URLClassLoader) so that repositories which are not
    standard webapp class repositories can be added to the classloader.
  - If the internal class loading fails, WebappClassLoader will now call
    super.findClass.
  - Implementation note : class and JAR reloading is not supported in non standard
    class repositories.
  - WebappClassLoader should now behave the same way StandardClassLoader
    did.
  - Should fix integration issues with the J2EE RI.
  
  Revision  Changes    Path
  1.8       +37 -10    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
  
  Index: WebappClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebappClassLoader.java	2001/06/26 21:02:18	1.7
  +++ WebappClassLoader.java	2001/07/12 21:22:25	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v 1.7 2001/06/26 21:02:18 glenn Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/06/26 21:02:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v 1.8 2001/07/12 21:22:25 remm Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/07/12 21:22:25 $
    *
    * ====================================================================
    *
  @@ -123,7 +123,7 @@
    *
    * @author Remy Maucherat
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2001/06/26 21:02:18 $
  + * @version $Revision: 1.8 $ $Date: 2001/07/12 21:22:25 $
    */
   public class WebappClassLoader
       extends URLClassLoader
  @@ -448,7 +448,19 @@
        */
       public void addRepository(String repository) {
   
  -        addRepository(repository, new File(repository));
  +        // Ignore any of the standard repositories, as they are set up using 
  +        // either addJar or addRepository
  +        if (repository.startsWith("/WEB-INF/lib")
  +            || repository.startsWith("/WEB-INF/classes"))
  +            return;
  +
  +        // Add this repository to our underlying class loader
  +        try {
  +            URL url = new URL(repository);
  +            super.addURL(url);
  +        } catch (MalformedURLException e) {
  +            throw new IllegalArgumentException(e.toString());
  +        }
   
       }
   
  @@ -463,7 +475,7 @@
        * @exception IllegalArgumentException if the specified repository is
        *  invalid or does not exist
        */
  -    public synchronized void addRepository(String repository, File file) {
  +    synchronized void addRepository(String repository, File file) {
   
           // Note : There should be only one (of course), but I think we should 
           // keep this a bit generic
  @@ -495,7 +507,7 @@
       }
   
   
  -    public synchronized void addJar(String jar, JarFile jarFile, File file)
  +    synchronized void addJar(String jar, JarFile jarFile, File file)
           throws IOException {
   
           if (jar == null)
  @@ -809,7 +821,7 @@
           Class clazz = null;
           try {
   	    if (debug >= 4)
  -	        log("      super.findClass(" + name + ")");
  +	        log("      findClassInternal(" + name + ")");
   	    try {
   	        clazz = findClassInternal(name);
               } catch(AccessControlException ace) {
  @@ -821,6 +833,17 @@
   		throw e;
   	    }
               if (clazz == null) {
  +                try {
  +                    clazz = super.findClass(name);
  +                } catch(AccessControlException ace) {
  +                    throw new ClassNotFoundException(name);
  +                } catch (RuntimeException e) {
  +                    if (debug >= 4)
  +                        log("      -->RuntimeException Rethrown", e);
  +                    throw e;
  +                }
  +            }
  +            if (clazz == null) {
                   if (debug >= 3)
                       log("    --> Returning ClassNotFoundException");
                   throw new ClassNotFoundException(name);
  @@ -1262,9 +1285,11 @@
        */
       public URL[] getURLs() {
   
  +        URL[] external = super.getURLs();
  +
           int filesLength = files.length;
           int jarFilesLength = jarRealFiles.length;
  -        int length = filesLength + jarFilesLength;
  +        int length = filesLength + jarFilesLength + external.length;
           int i;
   
           try {
  @@ -1273,8 +1298,10 @@
               for (i = 0; i < length; i++) {
                   if (i < filesLength) {
                       urls[i] = files[i].toURL();
  -                } else {
  +                } else if (i < filesLength + jarFilesLength) {
                       urls[i] = jarRealFiles[i - filesLength].toURL();
  +                } else {
  +                    urls[i] = external[i - filesLength - jarFilesLength];
                   }
               }
   
  
  
  

Re: cvs commit:jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loaderWebappClassLoader.java

Posted by Remy Maucherat <re...@apache.org>.
> on 7/12/01 2:22 PM, "remm@apache.org" <re...@apache.org> wrote:
> 
> > - Implementation note : class and JAR reloading is not supported in non
> > standard
> >   class repositories.
> 
> Define "non standard".

Not in the webapp repositories.

Remy


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java

Posted by Jon Stevens <jo...@latchkey.com>.
on 7/12/01 2:22 PM, "remm@apache.org" <re...@apache.org> wrote:

> - Implementation note : class and JAR reloading is not supported in non
> standard
>   class repositories.

Define "non standard".

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>