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/startup Bootstrap.java
Date Mon, 12 Feb 2001 21:27:32 GMT
remm        01/02/12 13:27:32

  Modified:    catalina/src/share/org/apache/catalina/startup
                        Bootstrap.java
  Log:
  - Fix for bug #556. Won't add bin/jndi.jar to the Catalina classoader if the
    JNDI classes can be loaded from the system classloader.
  
  Revision  Changes    Path
  1.11      +61 -51    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Bootstrap.java	2001/02/04 00:51:47	1.10
  +++ Bootstrap.java	2001/02/12 21:27:31	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
1.10 2001/02/04 00:51:47 glenn Exp $
  - * $Revision: 1.10 $
  - * $Date: 2001/02/04 00:51:47 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Bootstrap.java,v
1.11 2001/02/12 21:27:31 remm Exp $
  + * $Revision: 1.11 $
  + * $Date: 2001/02/12 21:27:31 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * class path and therefore not visible to application level classes.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.10 $ $Date: 2001/02/04 00:51:47 $
  + * @version $Revision: 1.11 $ $Date: 2001/02/12 21:27:31 $
    */
   
   public final class Bootstrap {
  @@ -121,36 +121,37 @@
           ClassLoader catalinaLoader = createCatalinaLoader(commonLoader);
           ClassLoader sharedLoader = createSharedLoader(commonLoader);
   
  -	// Load our startup class and call its process() method
  -	try {
  -
  -	    if( System.getSecurityManager() != null ) {
  -		// Pre load some classes required for SecurityManager
  -		// so that defineClassInPackage does not throw a
  -		// security exception.
  -		String basePackage = "org.apache.catalina.";
  -		catalinaLoader.loadClass(basePackage +
  -		    "core.ApplicationContext$PrivilegedGetRequestDispatcher");
  -                catalinaLoader.loadClass(basePackage +
  -                    "core.ApplicationDispatcher$PrivilegedForward");
  -                catalinaLoader.loadClass(basePackage +
  -                    "core.ApplicationDispatcher$PrivilegedInclude");
  -                catalinaLoader.loadClass(basePackage +
  -                    "session.StandardSession");
  -                catalinaLoader.loadClass(basePackage +
  -                    "util.Enumerator");
  -                catalinaLoader.loadClass(
  -		    "javax.servlet.http.Cookie");
  -	    }
  +        // Load our startup class and call its process() method
  +        try {
  +            
  +            if( System.getSecurityManager() != null ) {
  +                // Pre load some classes required for SecurityManager
  +                // so that defineClassInPackage does not throw a
  +                // security exception.
  +                String basePackage = "org.apache.catalina.";
  +                catalinaLoader.loadClass
  +                    (basePackage +
  +                     "core.ApplicationContext$PrivilegedGetRequestDispatcher");
  +                catalinaLoader.loadClass
  +                    (basePackage +
  +                     "core.ApplicationDispatcher$PrivilegedForward");
  +                catalinaLoader.loadClass
  +                    (basePackage +
  +                     "core.ApplicationDispatcher$PrivilegedInclude");
  +                catalinaLoader.loadClass
  +                    (basePackage + "session.StandardSession");
  +                catalinaLoader.loadClass(basePackage + "util.Enumerator");
  +                catalinaLoader.loadClass("javax.servlet.http.Cookie");
  +            }
   
               // Instantiate a startup class instance
               if (debug >= 1)
                   log("Loading startup class");
  -	    Class startupClass =
  -		catalinaLoader.loadClass
  +            Class startupClass =
  +                catalinaLoader.loadClass
                   ("org.apache.catalina.startup.Catalina");
  -	    Object startupInstance = startupClass.newInstance();
  -
  +            Object startupInstance = startupClass.newInstance();
  +            
               // Set the shared extensions class loader
               if (debug >= 1)
                   log("Setting startup class properties");
  @@ -162,26 +163,26 @@
               Method method =
                   startupInstance.getClass().getMethod(methodName, paramTypes);
               method.invoke(startupInstance, paramValues);
  -
  +            
               // Call the process() method
               if (debug >= 1)
                   log("Calling startup class process() method");
  -	    methodName = "process";
  -	    paramTypes = new Class[1];
  -	    paramTypes[0] = args.getClass();
  -	    paramValues = new Object[1];
  -	    paramValues[0] = args;
  -	    method =
  -		startupInstance.getClass().getMethod(methodName, paramTypes);
  -	    method.invoke(startupInstance, paramValues);
  -
  -	} catch (Exception e) {
  -	    System.out.println("Exception during startup processing");
  -	    e.printStackTrace(System.out);
  -	    System.exit(2);
  -	}
  +            methodName = "process";
  +            paramTypes = new Class[1];
  +            paramTypes[0] = args.getClass();
  +            paramValues = new Object[1];
  +            paramValues[0] = args;
  +            method =
  +                startupInstance.getClass().getMethod(methodName, paramTypes);
  +            method.invoke(startupInstance, paramValues);
  +            
  +        } catch (Exception e) {
  +            System.out.println("Exception during startup processing");
  +            e.printStackTrace(System.out);
  +            System.exit(2);
  +        }
   
  -	System.exit(0);
  +        System.exit(0);
   
       }
   
  @@ -195,6 +196,14 @@
           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();
   
  @@ -206,12 +215,13 @@
                                  + " does not exist");
               System.exit(1);
           }
  -	String filenames[] = directory.list();
  -	for (int i = 0; i < filenames.length; i++) {
  +        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))
  -		continue;
  +            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());
  @@ -224,7 +234,7 @@
                   e.printStackTrace(System.out);
                   System.exit(1);
               }
  -	}
  +        }
   
           // Construct the class loader itself
           String array[] = (String[]) list.toArray(new String[list.size()]);
  
  
  

Mime
View raw message