cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/servlet ParanoidCocoonServlet.java
Date Tue, 16 Sep 2003 16:54:28 GMT
sylvain     2003/09/16 09:54:28

  Modified:    src/java/org/apache/cocoon/servlet
                        ParanoidCocoonServlet.java
  Log:
  Allow entire library directories to be specified in the classpath file, instead of having
to list them explicitely
  
  Revision  Changes    Path
  1.9       +33 -15    cocoon-2.1/src/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java
  
  Index: ParanoidCocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ParanoidCocoonServlet.java	7 Aug 2003 06:26:24 -0000	1.8
  +++ ParanoidCocoonServlet.java	16 Sep 2003 16:54:28 -0000	1.9
  @@ -183,13 +183,7 @@
               
               // List all .jar and .zip
   			File libDir = new File(contextDir + "/WEB-INF/lib");
  -			File[] libraries = libDir.listFiles(
  -				new FilenameFilter() {
  -	                public boolean accept(File dir, String name) {
  -	                    return name.endsWith(".zip") || name.endsWith(".jar");
  -	                }
  -				}
  -			);
  +			File[] libraries = libDir.listFiles(new JarFileFilter());
   
   			for (int i = 0; i < libraries.length; i++) {
   				URL lib = libraries[i].toURL();
  @@ -222,15 +216,33 @@
               do {
                   line = lineReader.readLine();
                   if ( line != null ) {
  -                    final URL lib;
  -                    if ( line.indexOf(':') == -1) {
  -                        File entry = new File(line);        
  -                        lib = entry.toURL();
  +                    if (line.startsWith("class-dir:")) {
  +                        line = line.substring("class-dir:".length()).trim();
  +                        URL url = new File(line).toURL();
  +                        log("Adding class directory " + url);
  +                        urlList.add(url);
  +                        
  +                    } else if (line.startsWith("lib-dir:")) {
  +                        line = line.substring("lib-dir:".length()).trim();
  +                        File dir = new File(line);
  +                        File[] libraries = dir.listFiles(new JarFileFilter());
  +                        log("Adding " + libraries.length + " libraries from " + dir.toURL());
  +                        for (int i = 0; i < libraries.length; i++) {
  +                            URL url = libraries[i].toURL();
  +                            urlList.add(url);
  +                        }
                       } else {
  -                        lib = new URL(line);
  +                        // Consider it as a URL
  +                        final URL lib;
  +                        if ( line.indexOf(':') == -1) {
  +                            File entry = new File(line);        
  +                            lib = entry.toURL();
  +                        } else {
  +                            lib = new URL(line);
  +                        }
  +                        log("Adding class URL " + lib);
  +                        urlList.add(lib);
                       }
  -                    log("Adding class library " + lib);
  -                    urlList.add(lib);
                   }
               } while ( line != null );
               lineReader.close();
  @@ -275,5 +287,11 @@
   
   		super.destroy();
   	}
  +    
  +    private class JarFileFilter implements FilenameFilter {
  +        public boolean accept(File dir, String name) {
  +            return name.endsWith(".zip") || name.endsWith(".jar");
  +        }
  +    }
   }
   
  
  
  

Mime
View raw message