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 StandardLoader.java
Date Wed, 21 Feb 2001 06:03:44 GMT
remm        01/02/20 22:03:44

  Modified:    catalina/src/share/org/apache/catalina/loader
                        StandardLoader.java
  Log:
  - Don't copy libraries to the work directory if they exist in the filesystem. The
    test used here is that ServletContext.getRealPath(path) returns a non null
    value. Modify Jasper's classpath generation accordingly.
  
  Revision  Changes    Path
  1.20      +52 -30    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java
  
  Index: StandardLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StandardLoader.java	2001/01/28 20:06:17	1.19
  +++ StandardLoader.java	2001/02/21 06:03:43	1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
1.19 2001/01/28 20:06:17 remm Exp $
  - * $Revision: 1.19 $
  - * $Date: 2001/01/28 20:06:17 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardLoader.java,v
1.20 2001/02/21 06:03:43 remm Exp $
  + * $Revision: 1.20 $
  + * $Date: 2001/02/21 06:03:43 $
    *
    * ====================================================================
    *
  @@ -112,7 +112,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.19 $ $Date: 2001/01/28 20:06:17 $
  + * @version $Revision: 1.20 $ $Date: 2001/02/21 06:03:43 $
    */
   
   public final class StandardLoader
  @@ -828,20 +828,31 @@
               return;
           }
   
  -        // Loading the work directory
  -        File workDir = 
  -            (File) servletContext.getAttribute(Globals.WORK_DIR_ATTR);
  +        String absoluteClassesPath = servletContext.getRealPath(classesName);
   
  -        if (workDir != null) {
  +        if (absoluteClassesPath != null) {
   
               if (!(classpath.equals("")))
                   classpath = File.pathSeparator + classpath;
  -            File classesDir = new File(workDir, classesName);
  -            classesDir.mkdirs();
  -            classpath = classesDir.getAbsolutePath() + classpath;
  +            classpath = absoluteClassesPath + classpath;
   
  -            copyDir(resources, classesDir);
  +        } else {
   
  +            // Loading the work directory
  +            File workDir = 
  +                (File) servletContext.getAttribute(Globals.WORK_DIR_ATTR);
  +
  +            if (workDir != null) {
  +                
  +                if (!(classpath.equals("")))
  +                    classpath = File.pathSeparator + classpath;
  +                File classesDir = new File(workDir, classesName);
  +                classesDir.mkdirs();
  +                classpath = classesDir.getAbsolutePath() + classpath;
  +                
  +                copyDir(resources, classesDir);
  +                
  +            }
           }
   
           servletContext.setAttribute(Globals.CLASS_PATH_ATTR, classpath);
  @@ -959,11 +970,13 @@
           if (workDir != null) {
   
               DirContext resources = container.getResources();
  -            String libName = "/WEB-INF/lib";
   
  +            String libName = "/WEB-INF/lib";
  +            
               File destDir = new File(workDir, libName);
  -            destDir.mkdirs();
  -
  +            if (servletContext.getRealPath(libName) != null)
  +                destDir.mkdirs();
  +            
               DirContext libDir = null;
               // Looking up directory /WEB-INF/lib in the context
               try {
  @@ -986,22 +999,31 @@
                           String filename = ncPair.getName();
                           if (!filename.endsWith(".jar"))
                               continue;
  -                        try {
  -                            URL fileURL = servletContext.getResource
  -                                (libName + "/" + filename);
  -                            log(" Adding '" + "file: " +
  -                                libName + "/" + filename + "'");
  -                            // Copying the file to the work dir
  -                            File dest = new File(destDir, filename);
  -                            if (copy(fileURL.openStream(), 
  -                                     new FileOutputStream(dest))) {
  -                                if (n > 0)
  -                                    classpath.append(File.pathSeparator);
  -                                n++;
  -                                classpath.append(dest.getAbsolutePath());
  +                        String realPath = servletContext.getRealPath
  +                            (libName + "/" + filename);
  +                        if (realPath != null) {
  +                            if (n > 0)
  +                                classpath.append(File.pathSeparator);
  +                            n++;
  +                            classpath.append(realPath);
  +                        } else {
  +                            try {
  +                                URL fileURL = servletContext.getResource
  +                                    (libName + "/" + filename);
  +                                log(" Adding '" + "file: " +
  +                                    libName + "/" + filename + "'");
  +                                // Copying the file to the work dir
  +                                File dest = new File(destDir, filename);
  +                                if (copy(fileURL.openStream(), 
  +                                         new FileOutputStream(dest))) {
  +                                    if (n > 0)
  +                                        classpath.append(File.pathSeparator);
  +                                    n++;
  +                                    classpath.append(dest.getAbsolutePath());
  +                                }
  +                            } catch (MalformedURLException e) {
  +                            } catch (IOException e) {
                               }
  -                        } catch (MalformedURLException e) {
  -                        } catch (IOException e) {
                           }
                           
                       }
  
  
  

Mime
View raw message