tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1239522 - in /tomcat/trunk/java/org/apache/catalina: Server.java core/ContainerBase.java core/StandardEngine.java core/StandardServer.java mbeans/MBeanFactory.java startup/Tomcat.java
Date Thu, 02 Feb 2012 10:32:34 GMT
Author: markt
Date: Thu Feb  2 10:32:34 2012
New Revision: 1239522

URL: http://svn.apache.org/viewvc?rev=1239522&view=rev
Log:
Extend clean-up to Server

Modified:
    tomcat/trunk/java/org/apache/catalina/Server.java
    tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java
    tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
    tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
    tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java

Modified: tomcat/trunk/java/org/apache/catalina/Server.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Server.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Server.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Server.java Thu Feb  2 10:32:34 2012
@@ -18,6 +18,8 @@
 
 package org.apache.catalina;
 
+import java.io.File;
+
 import org.apache.catalina.deploy.NamingResources;
 import org.apache.catalina.startup.Catalina;
 
@@ -139,6 +141,34 @@ public interface Server extends Lifecycl
      */
     public void setCatalina(Catalina catalina);
 
+
+    /**
+     * Obtain the configured base (instance) directory. Note that home and base
+     * may be the same (and are by default). If this is not set the value
+     * returned by {@link #getCatalinaHome()} will be used.
+     */
+    public File getCatalinaBase();
+
+    /**
+     * Set the configured base (instance) directory. Note that home and base
+     * may be the same (and are by default).
+     */
+    public void setCatalinaBase(File catalinaBase);
+
+
+    /**
+     * Obtain the configured home (binary) directory. Note that home and base
+     * may be the same (and are by default).
+     */
+    public File getCatalinaHome();
+
+    /**
+     * Set the configured home (binary) directory. Note that home and base
+     * may be the same (and are by default).
+     */
+    public void setCatalinaHome(File catalinaHome);
+
+
     // --------------------------------------------------------- Public Methods
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java Thu Feb  2 10:32:34 2012
@@ -294,8 +294,6 @@ public abstract class ContainerBase exte
     protected ThreadPoolExecutor startStopExecutor;
 
 
-    private File catalinaBase = null;
-
     // ------------------------------------------------------------- Properties
 
     @Override
@@ -1336,37 +1334,14 @@ public abstract class ContainerBase exte
     }
 
 
-    public void setCatalinaBase(File catalinaBase) {
-        this.catalinaBase = catalinaBase;
-    }
-
-
     @Override
     public File getCatalinaBase() {
 
-        if (catalinaBase != null) {
-            return catalinaBase;
-        }
-
-        if (parent != null) {
-            return parent.getCatalinaBase();
-        }
-
-        String base = System.getProperty(Globals.CATALINA_BASE_PROP);
-
-        if (base == null) {
-            base = System.getProperty(Globals.CATALINA_HOME_PROP);
-        }
-
-        if (base == null) {
-            // In theory this should never happen. In 'standard' usage the start
-            // scripts will set the system property. In embedded usage either
-            // the system property will be set or it will be set explicitly.
+        if (parent == null) {
             return null;
         }
 
-        catalinaBase =new File(base).getAbsoluteFile();
-        return catalinaBase;
+        return parent.getCatalinaBase();
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java Thu Feb  2 10:32:34 2012
@@ -18,6 +18,7 @@ package org.apache.catalina.core;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.File;
 import java.util.Locale;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -33,6 +34,7 @@ import org.apache.catalina.LifecycleEven
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Realm;
+import org.apache.catalina.Server;
 import org.apache.catalina.Service;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
@@ -354,6 +356,23 @@ public class StandardEngine extends Cont
         return (ClassLoader.getSystemClassLoader());
     }
 
+
+    @Override
+    public File getCatalinaBase() {
+        if (service != null) {
+            Server s = service.getServer();
+            if (s != null) {
+                File base = s.getCatalinaBase();
+                if (base != null) {
+                    return base;
+                }
+            }
+        }
+        // Fall-back
+        return super.getCatalinaBase();
+    }
+
+
     // -------------------- JMX registration  --------------------
 
     @Override

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardServer.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Thu Feb  2 10:32:34 2012
@@ -18,6 +18,7 @@ package org.apache.catalina.core;
 
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetAddress;
@@ -160,8 +161,12 @@ public final class StandardServer extend
      */
     private volatile ServerSocket awaitSocket = null;
 
-    // ------------------------------------------------------------- Properties
+    private File catalinaHome = null;
+
+    private File catalinaBase = null;
+
 
+    // ------------------------------------------------------------- Properties
 
     /**
      * Return the global naming resources context.
@@ -583,9 +588,37 @@ public final class StandardServer extend
     }
 
 
-    // --------------------------------------------------------- Public Methods
+    @Override
+    public File getCatalinaBase() {
+        if (catalinaBase != null) {
+            return catalinaBase;
+        }
+
+        catalinaBase = getCatalinaHome();
+        return catalinaBase;
+    }
 
 
+    @Override
+    public void setCatalinaBase(File catalinaBase) {
+        this.catalinaBase = catalinaBase;
+    }
+
+
+    @Override
+    public File getCatalinaHome() {
+        return catalinaHome;
+    }
+
+
+    @Override
+    public void setCatalinaHome(File catalinaHome) {
+        this.catalinaHome = catalinaHome;
+    }
+
+
+    // --------------------------------------------------------- Public Methods
+
     /**
      * Add a property change listener to this component.
      *

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java Thu Feb  2 10:32:34 2012
@@ -683,7 +683,6 @@ public class MBeanFactory {
         engine.setDomain(domain);
         engine.setName(domain);
         engine.setDefaultHost(defaultHost);
-        engine.setCatalinaBase(new File(baseDir));
 
         Service service = new StandardService();
         service.setContainer(engine);

Modified: tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=1239522&r1=1239521&r2=1239522&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/Tomcat.java Thu Feb  2 10:32:34 2012
@@ -459,11 +459,12 @@ public class Tomcat {
             return server;
         }
 
-        initBaseDir();
-
         System.setProperty("catalina.useNaming", "false");
 
         server = new StandardServer();
+
+        initBaseDir();
+
         server.setPort( -1 );
 
         service = new StandardService();
@@ -591,20 +592,31 @@ public class Tomcat {
             // Create a temp dir.
             basedir = System.getProperty("user.dir") +
                 "/tomcat." + port;
-            File home = new File(basedir);
-            home.mkdir();
-            if (!home.isAbsolute()) {
+        }
+
+        File baseFile = new File(basedir);
+        baseFile.mkdirs();
+        if (!baseFile.isAbsolute()) {
+            try {
+                baseFile = baseFile.getCanonicalFile();
+            } catch (IOException e) {
+                baseFile = baseFile.getAbsoluteFile();
+            }
+        }
+        server.setCatalinaBase(baseFile);
+
+        if (catalinaHome == null) {
+            File homeFile = new File(catalinaHome);
+            homeFile.mkdirs();
+            if (!homeFile.isAbsolute()) {
                 try {
-                    basedir = home.getCanonicalPath();
+                    homeFile = homeFile.getCanonicalFile();
                 } catch (IOException e) {
-                    basedir = home.getAbsolutePath();
+                    homeFile = homeFile.getAbsoluteFile();
                 }
             }
+            server.setCatalinaBase(homeFile);
         }
-        if (catalinaHome == null) {
-            System.setProperty(Globals.CATALINA_HOME_PROP, basedir);
-        }
-        System.setProperty(Globals.CATALINA_BASE_PROP, basedir);
     }
 
     static final String[] silences = new String[] {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message