You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/09/21 17:59:56 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup ClassLoaderFactory.java Bootstrap.java BootstrapService.java

craigmcc    01/09/21 08:59:56

  Modified:    catalina Tag: tomcat_40_branch build.xml
               catalina/src/share/org/apache/catalina/startup Tag:
                        tomcat_40_branch Bootstrap.java
                        BootstrapService.java
  Added:       catalina/src/share/org/apache/catalina/startup Tag:
                        tomcat_40_branch ClassLoaderFactory.java
  Log:
  Make the process of building class loaders much smarter about technologies
  that have been integrated into later versions of the JDK.  It is not
  sufficient to check for JAR files by name (jndi.jar or ldap.jar) because
  users often rename JAR files.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.60.2.3  +2 -0      jakarta-tomcat-4.0/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/build.xml,v
  retrieving revision 1.60.2.2
  retrieving revision 1.60.2.3
  diff -u -r1.60.2.2 -r1.60.2.3
  --- build.xml	2001/09/20 17:41:03	1.60.2.2
  +++ build.xml	2001/09/21 15:59:55	1.60.2.3
  @@ -319,6 +319,7 @@
           <include name="org/apache/service/ServiceController.class" />
           <include name="org/apache/catalina/startup/Bootstrap.class" />
           <include name="org/apache/catalina/startup/BootstrapService.class" />
  +        <include name="org/apache/catalina/startup/ClassLoaderFactory.class" />
           <include name="org/apache/catalina/loader/StandardClassLoader*.class" />
           <include name="org/apache/catalina/loader/Extension.class" />
           <include name="org/apache/catalina/loader/Reloader.class" />
  @@ -334,6 +335,7 @@
           <exclude name="**/connector/warp/**" />
           <exclude name="org/apache/catalina/startup/Bootstrap.class" />
           <exclude name="org/apache/catalina/startup/BootstrapService.class" />
  +        <exclude name="org/apache/catalina/startup/ClassLoaderFactory.class" />
           <exclude name="org/apache/catalina/loader/StandardClassLoader*.class" />
           <exclude name="org/apache/catalina/loader/Extension.class" />
           <exclude name="org/apache/catalina/loader/Reloader.class" />
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.26.2.1  +56 -247   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java
  
  Index: Bootstrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
  retrieving revision 1.26
  retrieving revision 1.26.2.1
  diff -u -r1.26 -r1.26.2.1
  --- Bootstrap.java	2001/09/13 14:26:18	1.26
  +++ Bootstrap.java	2001/09/21 15:59:56	1.26.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v 1.26 2001/09/13 14:26:18 glenn Exp $
  - * $Revision: 1.26 $
  - * $Date: 2001/09/13 14:26:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v 1.26.2.1 2001/09/21 15:59:56 craigmcc Exp $
  + * $Revision: 1.26.2.1 $
  + * $Date: 2001/09/21 15:59:56 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * class path and therefore not visible to application level classes.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.26 $ $Date: 2001/09/13 14:26:18 $
  + * @version $Revision: 1.26.2.1 $ $Date: 2001/09/21 15:59:56 $
    */
   
   public final class Bootstrap {
  @@ -116,24 +116,49 @@
                   debug = 1;
           }
   
  -        // Check to see if JNDI is already present in the system classpath
  -        boolean loadJNDI = true;
  -        try {
  -            Class.forName("javax.naming.Context");
  -            loadJNDI = false;
  -        } catch (ClassNotFoundException e) {
  -        }
  -
           // Configure catalina.base from catalina.home if not yet set
           if (System.getProperty("catalina.base") == null)
               System.setProperty("catalina.base", getCatalinaHome());
   
           // Construct the class loaders we will need
  -        ClassLoader commonLoader = createCommonLoader(loadJNDI);
  -        ClassLoader catalinaLoader =
  -            createCatalinaLoader(commonLoader, loadJNDI);
  -        ClassLoader sharedLoader =
  -            createSharedLoader(commonLoader, loadJNDI);
  +        ClassLoader commonLoader = null;
  +        ClassLoader catalinaLoader = null;
  +        ClassLoader sharedLoader = null;
  +        try {
  +
  +            File unpacked[] = new File[1];
  +            File packed[] = new File[1];
  +            ClassLoaderFactory.setDebug(debug);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "common" + File.separator + "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "common" + File.separator + "lib");
  +            commonLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed, null);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "server" + File.separator + "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "server" + File.separator + "lib");
  +            catalinaLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                     commonLoader);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "lib");
  +            sharedLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                     commonLoader);
  +
  +        } catch (Throwable t) {
  +
  +            log("Class loader creation threw exception", t);
  +            System.exit(1);
  +
  +        }
   
           Thread.currentThread().setContextClassLoader(catalinaLoader);
   
  @@ -229,236 +254,6 @@
   
   
       /**
  -     * Construct and return the class loader to be used for loading
  -     * of the shared system classes.
  -     *
  -     * @param loadJNDI Should we load JNDI classes if present?
  -     */
  -    private static ClassLoader createCommonLoader(boolean loadJNDI) {
  -
  -        if (debug >= 1)
  -            log("Creating COMMON class loader");
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "common/classes" directory if it exists
  -        File classes = new File(getCatalinaHome(),
  -                                "common" + File.separator + "classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "common/lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "common/lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            String filename = filenames[i].toLowerCase();
  -            if (!filename.endsWith(".jar"))
  -                continue;
  -            if ((!loadJNDI) && filename.equals("jndi.jar"))
  -                continue;
  -            if (filename.equals("bootstrap.jar"))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array);
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
  -     * Construct and return the class loader to be used for loading
  -     * Catalina internal classes.
  -     *
  -     * @param parent Parent class loader to be assigned
  -     * @param loadJNDI Should we load JNDI classes if present?
  -     */
  -    private static ClassLoader createCatalinaLoader(ClassLoader parent,
  -                                                    boolean loadJNDI) {
  -
  -        if (debug >= 1)
  -            log("Creating CATALINA class loader");
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "server/classes" directory if it exists
  -        File classes = new File(getCatalinaHome(),
  -                                "server" + File.separator + "classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "server/lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "server/lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            String filename = filenames[i].toLowerCase();
  -            if (!filename.endsWith(".jar"))
  -                continue;
  -            if ((!loadJNDI) && filename.equals("jndi.jar"))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array, parent);
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
  -     * Construct and return the class loader to be used for shared
  -     * extensions by web applications loaded with Catalina.
  -     *
  -     * @param parent Parent class loader to be assigned
  -     * @param loadJNDI Should we load JNDI classes if present?
  -     */
  -    private static ClassLoader createSharedLoader(ClassLoader parent,
  -                                                  boolean loadJNDI) {
  -
  -        if (debug >= 1)
  -            log("Creating SHARED class loader");
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "classes" directory if it exists
  -        File classes = new File(getCatalinaHome(), "classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            String filename = filenames[i].toLowerCase();
  -            if (!filename.endsWith(".jar"))
  -                continue;
  -            if ((!loadJNDI) && filename.equals("jndi.jar"))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array, parent);
  -
  -        /*
  -        System.out.println("AVAILABLE OPTIONAL PACKAGES:");
  -        Extension available[] = loader.findAvailable();
  -        for (int i = 0; i < available.length; i++)
  -            System.out.println(available[i].toString());
  -        System.out.println("REQUIRED OPTIONAL PACKAGES:");
  -        Extension required[] = loader.findRequired();
  -        for (int i = 0; i < required.length; i++)
  -            System.out.println(required[i].toString());
  -        System.out.println("===========================");
  -        */
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
        * Get the value of the catalina.home environment variable.
        */
       private static String getCatalinaHome() {
  @@ -476,6 +271,20 @@
   
           System.out.print("Bootstrap: ");
           System.out.println(message);
  +
  +    }
  +
  +
  +    /**
  +     * Log a debugging detail message with an exception.
  +     *
  +     * @param message The message to be logged
  +     * @param exception The exception to be logged
  +     */
  +    private static void log(String message, Throwable exception) {
  +
  +        log(message);
  +        exception.printStackTrace(System.out);
   
       }
   
  
  
  
  1.7.2.1   +95 -231   jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java
  
  Index: BootstrapService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- BootstrapService.java	2001/09/13 14:26:18	1.7
  +++ BootstrapService.java	2001/09/21 15:59:56	1.7.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java,v 1.7 2001/09/13 14:26:18 glenn Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/09/13 14:26:18 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java,v 1.7.2.1 2001/09/21 15:59:56 craigmcc Exp $
  + * $Revision: 1.7.2.1 $
  + * $Date: 2001/09/21 15:59:56 $
    *
    * ====================================================================
    *
  @@ -86,7 +86,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.7 $ $Date: 2001/09/13 14:26:18 $
  + * @version $Revision: 1.7.2.1 $ $Date: 2001/09/21 15:59:56 $
    */
   
   public final class BootstrapService 
  @@ -130,11 +130,44 @@
           setCatalinaBase();
   
           // Construct the class loaders we will need
  -        ClassLoader commonLoader = createCommonLoader();
  -        ClassLoader catalinaLoader =
  -            createCatalinaLoader(commonLoader);
  -        ClassLoader sharedLoader = createSharedLoader(commonLoader);
  -        
  +        ClassLoader commonLoader = null;
  +        ClassLoader catalinaLoader = null;
  +        ClassLoader sharedLoader = null;
  +        try {
  +
  +            File unpacked[] = new File[1];
  +            File packed[] = new File[1];
  +            ClassLoaderFactory.setDebug(debug);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "common" + File.separator + "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "common" + File.separator + "lib");
  +            commonLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed, null);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "server" + File.separator + "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "server" + File.separator + "lib");
  +            catalinaLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                     commonLoader);
  +
  +            unpacked[0] = new File(getCatalinaHome(),
  +                                   "classes");
  +            packed[0] = new File(getCatalinaHome(),
  +                                 "lib");
  +            sharedLoader =
  +                ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                     commonLoader);
  +
  +        } catch (Throwable t) {
  +
  +            log("Class loader creation threw exception", t);
  +
  +        }
  +
           Thread.currentThread().setContextClassLoader(catalinaLoader);
           
           // Load our startup class and call its process() method
  @@ -271,10 +304,45 @@
                   System.out.println("Create Catalina server");
   
                   // Construct the class loaders we will need
  -                ClassLoader commonLoader = createCommonLoader();
  -                ClassLoader catalinaLoader =
  -                    createCatalinaLoader(commonLoader);
  -                ClassLoader sharedLoader = createSharedLoader(commonLoader);
  +                ClassLoader commonLoader = null;
  +                ClassLoader catalinaLoader = null;
  +                ClassLoader sharedLoader = null;
  +                try {
  +
  +                    File unpacked[] = new File[1];
  +                    File packed[] = new File[1];
  +                    ClassLoaderFactory.setDebug(debug);
  +
  +                    unpacked[0] = new File(getCatalinaHome(),
  +                                           "common" + File.separator + "classes");
  +                    packed[0] = new File(getCatalinaHome(),
  +                                         "common" + File.separator + "lib");
  +                    commonLoader =
  +                        ClassLoaderFactory.createClassLoader(unpacked, packed, null);
  +
  +                    unpacked[0] = new File(getCatalinaHome(),
  +                                           "server" + File.separator + "classes");
  +                    packed[0] = new File(getCatalinaHome(),
  +                                         "server" + File.separator + "lib");
  +                    catalinaLoader =
  +                        ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                             commonLoader);
  +
  +                    unpacked[0] = new File(getCatalinaHome(),
  +                                           "classes");
  +                    packed[0] = new File(getCatalinaHome(),
  +                                         "lib");
  +                    sharedLoader =
  +                        ClassLoaderFactory.createClassLoader(unpacked, packed,
  +                                                             commonLoader);
  +
  +                } catch (Throwable t) {
  +
  +                    log("Class loader creation threw exception", t);
  +                    System.exit(1);
  +
  +                }
  +
   
                   Thread.currentThread().setContextClassLoader(catalinaLoader);
   
  @@ -371,224 +439,6 @@
   
   
       /**
  -     * Construct and return the class loader to be used for loading
  -     * of the shared system classes.
  -     */
  -    private static ClassLoader createCommonLoader() {
  -
  -        if (debug >= 1)
  -            log("Creating COMMON class loader");
  -
  -        // Check to see if JNDI is already present in the system classpath
  -        boolean loadJNDI = true;
  -        try {
  -            Class.forName("javax.naming.Context");
  -            loadJNDI = false;
  -        } catch (ClassNotFoundException e) {
  -        }
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "common/classes" directory if it exists
  -        File classes = new File(getCatalinaHome(), "common/classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "common/lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "common/lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            String filename = filenames[i].toLowerCase();
  -            if ((!filename.endsWith(".jar")) ||
  -                (filename.indexOf("bootstrap.jar") != -1) ||
  -                ((!loadJNDI) && (filename.indexOf("jndi.jar") != -1)))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array);
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
  -     * Construct and return the class loader to be used for loading
  -     * Catalina internal classes.
  -     */
  -    private static ClassLoader createCatalinaLoader(ClassLoader parent) {
  -
  -        if (debug >= 1)
  -            log("Creating CATALINA class loader");
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "server/classes" directory if it exists
  -        File classes = new File(getCatalinaHome(), "server/classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "server/lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "server/lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            if (!filenames[i].toLowerCase().endsWith(".jar"))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array, parent);
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
  -     * Construct and return the class loader to be used for shared
  -     * extensions by web applications loaded with Catalina.
  -     */
  -    private static ClassLoader createSharedLoader(ClassLoader parent) {
  -
  -        if (debug >= 1)
  -            log("Creating SHARED class loader");
  -
  -        // Construct the "class path" for this class loader
  -        ArrayList list = new ArrayList();
  -
  -        // Add the "classes" directory if it exists
  -        File classes = new File(getCatalinaHome(), "classes");
  -        if (classes.exists() && classes.canRead() &&
  -            classes.isDirectory()) {
  -            try {
  -                URL url = new URL("file", null,
  -                                  classes.getCanonicalPath() + File.separator);
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   classes.getAbsolutePath());
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Add all JAR files in the "lib" directory if it exists
  -        File directory = new File(getCatalinaHome(), "lib");
  -        if (!directory.exists() || !directory.canRead() ||
  -            !directory.isDirectory()) {
  -            System.out.println("Directory " + directory.getAbsolutePath()
  -                               + " does not exist");
  -            System.exit(1);
  -        }
  -        String filenames[] = directory.list();
  -        for (int i = 0; i < filenames.length; i++) {
  -            if (!filenames[i].toLowerCase().endsWith(".jar"))
  -                continue;
  -            File file = new File(directory, filenames[i]);
  -            try {
  -                URL url = new URL("file", null, file.getCanonicalPath());
  -                if (debug >= 1)
  -                    log("  Adding " + url.toString());
  -                list.add(url.toString());
  -            } catch (IOException e) {
  -                System.out.println("Cannot create URL for " +
  -                                   filenames[i]);
  -                e.printStackTrace(System.out);
  -                System.exit(1);
  -            }
  -        }
  -
  -        // Construct the class loader itself
  -        String array[] = (String[]) list.toArray(new String[list.size()]);
  -        StandardClassLoader loader = new StandardClassLoader(array, parent);
  -
  -        /*
  -        System.out.println("AVAILABLE OPTIONAL PACKAGES:");
  -        Extension available[] = loader.findAvailable();
  -        for (int i = 0; i < available.length; i++)
  -            System.out.println(available[i].toString());
  -        System.out.println("REQUIRED OPTIONAL PACKAGES:");
  -        Extension required[] = loader.findRequired();
  -        for (int i = 0; i < required.length; i++)
  -            System.out.println(required[i].toString());
  -        System.out.println("===========================");
  -        */
  -
  -        return (loader);
  -
  -    }
  -
  -
  -    /**
        * Set the <code>catalina.base</code> System property to the current
        * working directory if it has not been set.
        */
  @@ -638,6 +488,20 @@
   
           System.out.print("Bootstrap: ");
           System.out.println(message);
  +
  +    }
  +
  +
  +    /**
  +     * Log a debugging detail message with an exception.
  +     *
  +     * @param message The message to be logged
  +     * @param exception The exception to be logged
  +     */
  +    private static void log(String message, Throwable exception) {
  +
  +        log(message);
  +        exception.printStackTrace(System.out);
   
       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +359 -0    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Attic/ClassLoaderFactory.java