tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1239516 - in /tomcat/trunk/java/org/apache/catalina: Container.java core/ContainerBase.java startup/FailedContext.java
Date Thu, 02 Feb 2012 10:28:48 GMT
Author: markt
Date: Thu Feb  2 10:28:48 2012
New Revision: 1239516

URL: http://svn.apache.org/viewvc?rev=1239516&view=rev
Log:
Add the plumbing to make a canonical CATALINA_BASE File available via
every 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/startup/FailedContext.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=1239516&r1=1239515&r2=1239516&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Container.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Container.java Thu Feb  2 10:28:48 2012
@@ -18,6 +18,7 @@ package org.apache.catalina;
 
 
 import java.beans.PropertyChangeListener;
+import java.io.File;
 
 import javax.management.ObjectName;
 import javax.naming.directory.DirContext;
@@ -443,4 +444,10 @@ public interface Container extends Lifec
      * @param   startStopThreads    The new number of threads to be used
      */
     public void setStartStopThreads(int startStopThreads);
+
+
+    /**
+     *
+     */
+    public File getCatalinaBase();
 }

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=1239516&r1=1239515&r2=1239516&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:28:48 2012
@@ -19,6 +19,8 @@ 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;
@@ -292,6 +294,9 @@ public abstract class ContainerBase exte
     private int startStopThreads = 1;
     protected ThreadPoolExecutor startStopExecutor;
 
+
+    private File catalinaBase = null;
+
     // ------------------------------------------------------------- Properties
 
     @Override
@@ -1332,8 +1337,34 @@ public abstract class ContainerBase exte
     }
 
 
-    // ------------------------------------------------------ Protected Methods
+    @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) {
+            return null;
+        } else {
+            File f;
+            try {
+                f = new File(base).getCanonicalFile();
+            } catch (IOException e) {
+                return null;
+            }
+            return f;
+        }
+    }
+
+
+    // ------------------------------------------------------ Protected Methods
 
     /**
      * Notify all container event listeners that a particular event has

Modified: tomcat/trunk/java/org/apache/catalina/startup/FailedContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/FailedContext.java?rev=1239516&r1=1239515&r2=1239516&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/FailedContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/FailedContext.java Thu Feb  2 10:28:48 2012
@@ -17,6 +17,7 @@
 package org.apache.catalina.startup;
 
 import java.beans.PropertyChangeListener;
+import java.io.File;
 import java.net.URL;
 import java.util.Set;
 
@@ -634,4 +635,7 @@ public class FailedContext extends Lifec
 
     @SuppressWarnings("unused")
     public synchronized void addValve(Valve valve) { /* NO-OP */ }
+
+    @Override
+    public File getCatalinaBase() { return null; }
 }
\ No newline at end of file



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


Mime
View raw message