remm        01/07/12 14:24:15

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappLoader.java
  Log:
  - Cleanup of the classpath generation.
  - Implemented addRepository the way it was implemented in StandardLoader.
  - Should fix integration issues with the J2EE RI.
  
  Revision  Changes    Path
  1.8       +25 -36    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappLoader.java
  
  Index: WebappLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebappLoader.java 2001/06/23 22:30:04     1.7
  +++ WebappLoader.java 2001/07/12 21:24:09     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappLoader.java,v
 1.7 2001/06/23 22:30:04 remm Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/06/23 22:30:04 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappLoader.java,v
 1.8 2001/07/12 21:24:09 remm Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/07/12 21:24:09 $
    *
    * ====================================================================
    *
  @@ -119,7 +119,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.7 $ $Date: 2001/06/23 22:30:04 $
  + * @version $Revision: 1.8 $ $Date: 2001/07/12 21:24:09 $
    */
   
   public class WebappLoader
  @@ -267,13 +267,6 @@
       private String threadName = "WebappLoader";
   
   
  -    /**
  -     * Classpath (which can be used by any webapp which would need to compile
  -     * classes, like a JSP engine.
  -     */
  -    protected StringBuffer classpath = new StringBuffer();
  -
  -
       // ------------------------------------------------------------- Properties
   
   
  @@ -493,6 +486,7 @@
   
           if (debug >= 1)
            log(sm.getString("webappLoader.addRepository", repository));
  +
           for (int i = 0; i < repositories.length; i++) {
               if (repository.equals(repositories[i]))
                   return;
  @@ -503,6 +497,11 @@
        results[repositories.length] = repository;
        repositories = results;
   
  +     if (started && (classLoader != null)) {
  +         classLoader.addRepository(repository);
  +         setClassPath();
  +     }
  +
       }
   
   
  @@ -618,9 +617,13 @@
               classLoader.setDebug(this.debug);
               classLoader.setDelegate(this.delegate);
   
  +            for (int i = 0; i < repositories.length; i++) {
  +                classLoader.addRepository(repositories[i]);
  +            }
  +
               // Configure our repositories
  -            setClassPath();
               setRepositories();
  +            setClassPath();
   
            if (container instanceof Context) {
                // Tell the class loader the root of the context
  @@ -832,9 +835,6 @@
   
           log(sm.getString("webappLoader.deploy", workDir.getAbsolutePath()));
   
  -        // Reset repositories
  -        repositories = new String[0];
  -
           DirContext resources = container.getResources();
   
           // Setting up the class repository (/WEB-INF/classes), if it exists
  @@ -861,18 +861,12 @@
   
               if (absoluteClassesPath != null) {
   
  -                if (classpath.length() != 0)
  -                    classpath.append(File.pathSeparator);
  -                classpath.append(absoluteClassesPath);
                   classRepository = new File(absoluteClassesPath);
   
               } else {
                   
  -                if (classpath.length() != 0)
  -                    classpath.append(File.pathSeparator);
                   classRepository = new File(workDir, classesPath);
                   classRepository.mkdirs();
  -                classpath.append(classRepository.getAbsolutePath());
                   
                   log(sm.getString("webappLoader.classDeploy", classesPath,
                                    classRepository.getAbsolutePath()));
  @@ -884,9 +878,6 @@
               // Adding the repository to the class loader
               classLoader.addRepository(classesPath + "/", classRepository);
   
  -            // Add to the local repository list
  -            addRepository(classesPath + "/");
  -
           }
   
           // Setting up the JAR repository (/WEB-INF/lib), if it exists
  @@ -946,30 +937,20 @@
                               continue;
                       }
   
  -                    if (classpath.length() != 0)
  -                        classpath.append(File.pathSeparator);
  -                    classpath.append(destFile.getAbsolutePath());
  -
                       JarFile jarFile = new JarFile(destFile);
   
                       classLoader.addJar(filename, jarFile, destFile);
  -                    addRepository(filename);
   
                   }
               } catch (NamingException e) {
                   // Silent catch: it's valid that no /WEB-INF/lib directory 
  -                //exists
  -                e.printStackTrace();
  +                // exists
               } catch (IOException e) {
                   e.printStackTrace();
               }
               
           }
   
  -        // Store the assembled class path as a servlet context attribute
  -        servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
  -                                    classpath.toString());
  -
       }
   
   
  @@ -987,6 +968,8 @@
        if (servletContext == null)
            return;
   
  +        StringBuffer classpath = new StringBuffer();
  +
           // Assemble the class path information from our class loader chain
           ClassLoader loader = getClassLoader();
           int layers = 0;
  @@ -1000,6 +983,8 @@
                   String repository = repositories[i].toString();
                   if (repository.startsWith("file://"))
                       repository = repository.substring(7);
  +                else if (repository.startsWith("file:/"))
  +                    repository = repository.substring(6);
                   else if (repository.startsWith("file:"))
                       repository = repository.substring(5);
                   else if (repository.startsWith("jndi:"))
  @@ -1007,7 +992,7 @@
                           servletContext.getRealPath(repository.substring(5));
                   else
                       continue;
  -                if ((repository == null) || (repository.endsWith("/")))
  +                if (repository == null)
                       continue;
                   if (n > 0)
                       classpath.append(File.pathSeparator);
  @@ -1017,6 +1002,10 @@
               loader = loader.getParent();
               layers++;
           }
  +
  +        // Store the assembled class path as a servlet context attribute
  +        servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
  +                                    classpath.toString());
   
       }
   
  
  
  

Reply via email to