tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java
Date Sat, 20 Oct 2001 18:19:25 GMT
remm        01/10/20 11:19:25

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappClassLoader.java
  Log:
  - Add an optimization to avoid calling the superclass if there are no external
    repositories.
  - getResource and getResourceAsStream weren't calling the superclass
    (which is needed when there are external repositories).
  
  Revision  Changes    Path
  1.22      +32 -11    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- WebappClassLoader.java	2001/10/11 20:59:55	1.21
  +++ WebappClassLoader.java	2001/10/20 18:19:25	1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.21 2001/10/11 20:59:55 remm Exp $
  - * $Revision: 1.21 $
  - * $Date: 2001/10/11 20:59:55 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.22 2001/10/20 18:19:25 remm Exp $
  + * $Revision: 1.22 $
  + * $Date: 2001/10/20 18:19:25 $
    *
    * ====================================================================
    *
  @@ -124,7 +124,7 @@
    *
    * @author Remy Maucherat
    * @author Craig R. McClanahan
  - * @version $Revision: 1.21 $ $Date: 2001/10/11 20:59:55 $
  + * @version $Revision: 1.22 $ $Date: 2001/10/20 18:19:25 $
    */
   public class WebappClassLoader
       extends URLClassLoader
  @@ -341,6 +341,12 @@
       protected boolean started = false;
   
   
  +    /**
  +     * Has external repositories.
  +     */
  +    protected boolean hasExternalRepositories = false;
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -461,6 +467,7 @@
           try {
               URL url = new URL(repository);
               super.addURL(url);
  +            hasExternalRepositories = true;
           } catch (MalformedURLException e) {
               throw new IllegalArgumentException(e.toString());
           }
  @@ -858,7 +865,7 @@
                       log("      -->RuntimeException Rethrown", e);
                   throw e;
               }
  -            if (clazz == null) {
  +            if ((clazz == null) && hasExternalRepositories) {
                   try {
                       clazz = super.findClass(name);
                   } catch(AccessControlException ace) {
  @@ -918,6 +925,9 @@
               url = entry.source;
           }
   
  +        if ((url == null) && hasExternalRepositories)
  +            url = super.findResource(name);
  +
           if (debug >= 3) {
               if (url != null)
                   log("    --> Returning '" + url.toString() + "'");
  @@ -981,10 +991,14 @@
           }
   
           // Adding the results of a call to the superclass
  -        Enumeration otherResourcePaths = super.findResources(name);
  +        if (hasExternalRepositories) {
  +
  +            Enumeration otherResourcePaths = super.findResources(name);
  +
  +            while (otherResourcePaths.hasMoreElements()) {
  +                result.addElement(otherResourcePaths.nextElement());
  +            }
   
  -        while (otherResourcePaths.hasMoreElements()) {
  -            result.addElement(otherResourcePaths.nextElement());
           }
   
           return result.elements();
  @@ -1114,6 +1128,12 @@
               if (debug >= 2)
                   log("  --> Returning stream from local");
               stream = findLoadedResource(name);
  +            try {
  +                if (hasExternalRepositories && (stream == null))
  +                    stream = url.openStream();
  +            } catch (IOException e) {
  +                ; // Ignore
  +            }
               if (stream != null)
                   return (stream);
           }
  @@ -1438,6 +1458,7 @@
           jarNames = new String[0];
           lastModifiedDates = new long[0];
           paths = new String[0];
  +        hasExternalRepositories = false;
   
           required.clear();
           permissionList.clear();
  @@ -1560,9 +1581,6 @@
           if ((name == null) || (path == null))
               return null;
   
  -        if (notFoundResources.containsKey(name))
  -            return null;
  -
           ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
           if (entry != null)
               return entry;
  @@ -1627,6 +1645,9 @@
               } catch (NamingException e) {
               }
           }
  +
  +        if ((entry == null) && (notFoundResources.containsKey(name)))
  +            return null;
   
           JarEntry jarEntry = null;
   
  
  
  

Mime
View raw message