tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ServletLoader.java
Date Sat, 30 Oct 1999 05:10:43 GMT
gonzo       99/10/29 22:10:43

  Modified:    src/share/org/apache/tomcat/core Tag: TOMCAT_J2EE_10F_102199
                        ServletLoader.java
  Log:
  search WEB-INF/lib subdirs for all jar files - j2ee
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +50 -18    jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java
  
  Index: ServletLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ServletLoader.java	1999/10/28 01:04:20	1.2.2.1
  +++ ServletLoader.java	1999/10/30 05:10:42	1.2.2.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v
1.2.2.1 1999/10/28 01:04:20 gonzo Exp $
  - * $Revision: 1.2.2.1 $
  - * $Date: 1999/10/28 01:04:20 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v
1.2.2.2 1999/10/30 05:10:42 gonzo Exp $
  + * $Revision: 1.2.2.2 $
  + * $Date: 1999/10/30 05:10:42 $
    *
    * ====================================================================
    *
  @@ -361,7 +361,8 @@
   
   	    if (f.exists() &&
   	        f.isDirectory()) {
  -		String[] jars = getJarFiles(f);
  +                JarFinder jarFinder = new JarFinder();
  +		String[] jars = jarFinder.getJars(f);
   
   		for (int i = 0; i < jars.length; i++) {
   		    String s = f.toString() + File.separator + jars[i];
  @@ -407,7 +408,8 @@
   
                   if (f.exists() &&
                       f.isDirectory()) {
  -                    String[] jars = getJarFiles(f);
  +                    JarFinder jarFinder = new JarFinder();
  +		    String[] jars = jarFinder.getJars(f);
   
                       for (int i = 0; i < jars.length; i++) {
                           String s = f.toString() + File.separator +
  @@ -485,12 +487,6 @@
   	return baos.toByteArray();
       }
   
  -    private String[] getJarFiles(File f) {
  -        FilenameFilter filter = new JarFilter("jar");
  -
  -        return f.list(filter);
  -    }
  -
       private String classPathFormat(Enumeration e) {
           String cp = "";
   
  @@ -509,16 +505,52 @@
           return cp;
       }
   }
  +
  +class JarFinder {
  +    private Vector jars = null;
  +
  +    String[] getJars(String dir) {
  +        File f = new File(dir);
   
  -class JarFilter implements FilenameFilter {
  -    String extension = "";
  +        return getJars(f, null);
  +    }
  +
  +    String[] getJars(String dir, String path) {
  +        File f = new File(dir);
   
  -    JarFilter(String extension) {
  -        this.extension = extension;
  +        return getJars(f, path);
       }
  +
  +    String[] getJars(File dir) {
  +        return getJars(dir, null);
  +    }
  +
  +    private String[] getJars(File dir, String path) {
  +        File[] files = dir.listFiles();
  +
  +        for (int i = 0; i < files.length; i++) {
  +            File file = files[i];
  +            String p = (path != null) ? path + File.separator : "";
  +
  +            if (file.canRead()) {
  +                if (file.isFile() &&
  +                    file.getName().toLowerCase().endsWith(
  +                        "." + "jar")) {
  +                    if (this.jars == null) {
  +                        this.jars = new Vector();
  +                    }
  +
  +                    this.jars.addElement(p + file.getName());
  +                } else if (file.isDirectory()) {
  +                    getJars(file, p + file.getName());
  +                }
  +            }
  +        }
  +
  +        String[] jars = new String[this.jars.size()];
  +
  +        this.jars.copyInto((Object[])jars);
   
  -    public boolean accept(File dir, String name) {
  -        return (name != null &&
  -	    name.endsWith("." + this.extension));
  +        return jars;
       }
   }
  
  
  

Mime
View raw message