tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1239518 - in /tomcat/trunk/java/org/apache/catalina: Container.java core/ContainerBase.java core/StandardContext.java core/StandardEngine.java mbeans/MBeanFactory.java startup/ContextConfig.java
Date Thu, 02 Feb 2012 10:29:44 GMT
Author: markt
Date: Thu Feb  2 10:29:44 2012
New Revision: 1239518

URL: http://svn.apache.org/viewvc?rev=1239518&view=rev
Log:
Start to pull out the various custom methods to obtain CATALINA_BASE
and replace them with a call to the Container.

Modified:
    tomcat/trunk/java/org/apache/catalina/Container.java
    tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

Modified: tomcat/trunk/java/org/apache/catalina/Container.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Container.java?rev=1239518&r1=1239517&r2=1239518&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Container.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Container.java Thu Feb  2 10:29:44 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina;
 
-
 import java.beans.PropertyChangeListener;
 import java.io.File;
 

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=1239518&r1=1239517&r2=1239518&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:29:44 2012
@@ -20,7 +20,6 @@ package org.apache.catalina.core;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.io.File;
-import java.io.IOException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -1337,6 +1336,11 @@ public abstract class ContainerBase exte
     }
 
 
+    public void setCatalinaBase(File catalinaBase) {
+        this.catalinaBase = catalinaBase;
+    }
+
+
     @Override
     public File getCatalinaBase() {
 
@@ -1351,16 +1355,15 @@ public abstract class ContainerBase exte
         String base = System.getProperty(Globals.CATALINA_BASE_PROP);
 
         if (base == null) {
+            base = System.getProperty(Globals.CATALINA_HOME_PROP);
+        }
+
+        if (base == null) {
             return null;
-        } else {
-            File f;
-            try {
-                f = new File(base).getCanonicalFile();
-            } catch (IOException e) {
-                return null;
-            }
-            return f;
         }
+
+        catalinaBase =new File(base).getAbsoluteFile();
+        return catalinaBase;
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1239518&r1=1239517&r2=1239518&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Thu Feb  2 10:29:44 2012
@@ -2503,11 +2503,8 @@ public class StandardContext extends Con
         }
         File workDir = new File(getWorkDir());
         if (!workDir.isAbsolute()) {
-            File catalinaHome = engineBase();
-            String catalinaHomePath = null;
             try {
-                catalinaHomePath = catalinaHome.getCanonicalPath();
-                workDir = new File(catalinaHomePath,
+                workDir = new File(getCatalinaBase().getCanonicalFile(),
                         getWorkDir());
             } catch (IOException e) {
                 log.warn(sm.getString("standardContext.workPath", getName()),
@@ -5650,20 +5647,6 @@ public class StandardContext extends Con
 
 
     /**
-     * Return a File object representing the base directory for the
-     * entire servlet container (i.e. the Engine container if present).
-     */
-    protected File engineBase() {
-        String base=System.getProperty(Globals.CATALINA_BASE_PROP);
-        if( base == null ) {
-            StandardEngine eng=(StandardEngine)this.getParent().getParent();
-            base=eng.getBaseDir();
-        }
-        return (new File(base));
-    }
-
-
-    /**
      * Bind current thread, both for CL purposes and for JNDI ENC support
      * during : startup, shutdown and realoading of the context.
      *
@@ -5728,7 +5711,7 @@ public class StandardContext extends Con
         File file = new File(getDocBase());
         if (!file.isAbsolute()) {
             if (container == null) {
-                docBase = (new File(engineBase(), getDocBase())).getPath();
+                docBase = (new File(getCatalinaBase(), getDocBase())).getPath();
             } else {
                 // Use the "appBase" property of this container
                 file = ((Host) container).getAppBaseFile();
@@ -5921,10 +5904,9 @@ public class StandardContext extends Con
         // Create this directory if necessary
         File dir = new File(workDir);
         if (!dir.isAbsolute()) {
-            File catalinaHome = engineBase();
             String catalinaHomePath = null;
             try {
-                catalinaHomePath = catalinaHome.getCanonicalPath();
+                catalinaHomePath = getCatalinaBase().getCanonicalPath();
                 dir = new File(catalinaHomePath, workDir);
             } catch (IOException e) {
                 log.warn(sm.getString("standardContext.workCreateException",

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=1239518&r1=1239517&r2=1239518&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:29:44 2012
@@ -27,7 +27,6 @@ import org.apache.catalina.ContainerEven
 import org.apache.catalina.ContainerListener;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
@@ -207,20 +206,6 @@ public class StandardEngine extends Cont
         this.service = service;
     }
 
-    public String getBaseDir() {
-        if( baseDir==null ) {
-            baseDir=System.getProperty(Globals.CATALINA_BASE_PROP);
-        }
-        if( baseDir==null ) {
-            baseDir=System.getProperty(Globals.CATALINA_HOME_PROP);
-        }
-        return baseDir;
-    }
-
-    public void setBaseDir(String baseDir) {
-        this.baseDir = baseDir;
-    }
-
     // --------------------------------------------------------- Public Methods
 
 

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=1239518&r1=1239517&r2=1239518&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:29:44 2012
@@ -683,7 +683,7 @@ public class MBeanFactory {
         engine.setDomain(domain);
         engine.setName(domain);
         engine.setDefaultHost(defaultHost);
-        engine.setBaseDir(baseDir);
+        engine.setCatalinaBase(new File(baseDir));
 
         Service service = new StandardService();
         service.setContainer(engine);

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1239518&r1=1239517&r2=1239518&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Thu Feb  2 10:29:44 2012
@@ -67,7 +67,6 @@ import org.apache.catalina.Valve;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ContainerBase;
 import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.deploy.ErrorPage;
 import org.apache.catalina.deploy.FilterDef;
@@ -485,15 +484,6 @@ public class ContextConfig implements Li
     }
 
 
-    protected String getBaseDir() {
-        Container engineC=context.getParent().getParent();
-        if( engineC instanceof StandardEngine ) {
-            return ((StandardEngine)engineC).getBaseDir();
-        }
-        return System.getProperty(Globals.CATALINA_BASE_PROP);
-    }
-
-
     /**
      * Process the default configuration file, if it exists.
      */
@@ -513,7 +503,8 @@ public class ContextConfig implements Li
         if (!context.getOverride()) {
             File defaultContextFile = new File(defaultContextXml);
             if (!defaultContextFile.isAbsolute()) {
-                defaultContextFile =new File(getBaseDir(), defaultContextXml);
+                defaultContextFile =
+                        new File(context.getCatalinaBase(), defaultContextXml);
             }
             if (defaultContextFile.exists()) {
                 try {
@@ -1627,7 +1618,8 @@ public class ContextConfig implements Li
         if (Constants.NoDefaultWebXml.equals(defaultWebXml)) {
             return null;
         }
-        return getWebXmlSource(defaultWebXml, getBaseDir());
+        return getWebXmlSource(defaultWebXml,
+                context.getCatalinaBase().getPath());
     }
 
     /**



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


Mime
View raw message