You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/08/29 04:44:03 UTC

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

remm        01/08/28 19:44:03

  Modified:    catalina/src/share/org/apache/catalina/startup
                        BootstrapService.java
  Log:
  - Make BootstrapService catalina.base and catalina.home aware. Since it
    does not call Catalina.process in all situations, it has to set the two variables
    before calling load.
  
  Revision  Changes    Path
  1.4       +51 -16    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BootstrapService.java	2001/07/23 03:14:46	1.3
  +++ BootstrapService.java	2001/08/29 02:44:03	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java,v 1.3 2001/07/23 03:14:46 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/07/23 03:14:46 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/BootstrapService.java,v 1.4 2001/08/29 02:44:03 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/08/29 02:44:03 $
    *
    * ====================================================================
    *
  @@ -86,7 +86,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.3 $ $Date: 2001/07/23 03:14:46 $
  + * @version $Revision: 1.4 $ $Date: 2001/08/29 02:44:03 $
    */
   
   public final class BootstrapService 
  @@ -125,6 +125,10 @@
   
           System.out.println("Create Catalina server");
   
  +        // Set Catalina path
  +        setCatalinaBase();
  +        setCatalinaHome();
  +
           // Construct the class loaders we will need
           ClassLoader commonLoader = createCommonLoader();
           ClassLoader catalinaLoader =
  @@ -385,8 +389,7 @@
           ArrayList list = new ArrayList();
   
           // Add the "common/classes" directory if it exists
  -        File classes = new File(System.getProperty("catalina.home"),
  -                                "common/classes");
  +        File classes = new File(getCatalinaHome(), "common/classes");
           if (classes.exists() && classes.canRead() &&
               classes.isDirectory()) {
               try {
  @@ -404,8 +407,7 @@
           }
   
           // Add all JAR files in the "common/lib" directory if it exists
  -        File directory = new File(System.getProperty("catalina.home"),
  -                                  "common/lib");
  +        File directory = new File(getCatalinaHome(), "common/lib");
           if (!directory.exists() || !directory.canRead() ||
               !directory.isDirectory()) {
               System.out.println("Directory " + directory.getAbsolutePath()
  @@ -455,8 +457,7 @@
           ArrayList list = new ArrayList();
   
           // Add the "server/classes" directory if it exists
  -        File classes = new File(System.getProperty("catalina.home"),
  -                                "server/classes");
  +        File classes = new File(getCatalinaHome(), "server/classes");
           if (classes.exists() && classes.canRead() &&
               classes.isDirectory()) {
               try {
  @@ -474,8 +475,7 @@
           }
   
           // Add all JAR files in the "server/lib" directory if it exists
  -        File directory = new File(System.getProperty("catalina.home"),
  -                                  "server/lib");
  +        File directory = new File(getCatalinaHome(), "server/lib");
           if (!directory.exists() || !directory.canRead() ||
               !directory.isDirectory()) {
               System.out.println("Directory " + directory.getAbsolutePath()
  @@ -522,8 +522,7 @@
           ArrayList list = new ArrayList();
   
           // Add the "classes" directory if it exists
  -        File classes = new File(System.getProperty("catalina.home"),
  -                                "classes");
  +        File classes = new File(getCatalinaHome(), "classes");
           if (classes.exists() && classes.canRead() &&
               classes.isDirectory()) {
               try {
  @@ -541,8 +540,7 @@
           }
   
           // Add all JAR files in the "lib" directory if it exists
  -        File directory = new File(System.getProperty("catalina.home"),
  -                                  "lib");
  +        File directory = new File(getCatalinaHome(), "lib");
           if (!directory.exists() || !directory.canRead() ||
               !directory.isDirectory()) {
               System.out.println("Directory " + directory.getAbsolutePath()
  @@ -585,6 +583,43 @@
   
           return (loader);
   
  +    }
  +
  +
  +    /**
  +     * Set the <code>catalina.base</code> System property to the current
  +     * working directory if it has not been set.
  +     */
  +    private void setCatalinaBase() {
  +
  +        if (System.getProperty("catalina.base") != null)
  +            return;
  +        System.setProperty("catalina.base",
  +                           System.getProperty("user.dir"));
  +
  +    }
  +
  +
  +    /**
  +     * Set the <code>catalina.home</code> System property to the current
  +     * working directory if it has not been set.
  +     */
  +    private void setCatalinaHome() {
  +
  +        if (System.getProperty("catalina.home") != null)
  +            return;
  +        System.setProperty("catalina.home",
  +                           System.getProperty("user.dir"));
  +
  +    }
  +
  +
  +    /**
  +     * Get the value of the catalina.home environment variable.
  +     */
  +    private static String getCatalinaHome() {
  +        return System.getProperty("catalina.home",
  +                                  System.getProperty("user.dir"));
       }