You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2012/05/22 11:25:19 UTC

svn commit: r1341369 - /tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

Author: kfujino
Date: Tue May 22 09:25:18 2012
New Revision: 1341369

URL: http://svn.apache.org/viewvc?rev=1341369&view=rev
Log:
Enable host's xmlBase attribute in ContextConfig.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java

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=1341369&r1=1341368&r2=1341369&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Tue May 22 09:25:18 2012
@@ -512,8 +512,7 @@ public class ContextConfig implements Li
                 }
             }
 
-            File hostContextFile = new File(getConfigBase(),
-                    getHostConfigPath(Constants.HostContextXml));
+            File hostContextFile = new File(getHostConfigBase(), Constants.HostContextXml);
             if (hostContextFile.exists()) {
                 try {
                     URL hostContextUrl = hostContextFile.toURI().toURL();
@@ -1105,32 +1104,42 @@ public class ContextConfig implements Li
         return configBase;
     }
 
-
-    protected String getHostConfigPath(String resourceName) {
-        StringBuilder result = new StringBuilder();
+    protected File getHostConfigBase() {
+        File file = null;
         Container container = context;
-        Container host = null;
-        Container engine = null;
+        Host host = null;
+        Engine engine = null;
         while (container != null) {
             if (container instanceof Host) {
-                host = container;
+                host = (Host)container;
             }
             if (container instanceof Engine) {
-                engine = container;
+                engine = (Engine)container;
             }
             container = container.getParent();
         }
-        if (engine != null) {
-            result.append(engine.getName()).append('/');
+        if (host != null && host.getXmlBase()!=null) {
+            String xmlBase = host.getXmlBase();
+            file = new File(xmlBase);
+            if (!file.isAbsolute())
+                file = new File(context.getCatalinaBase(), xmlBase);
+        } else {
+            StringBuilder result = new StringBuilder();
+            if (engine != null) {
+                result.append(engine.getName()).append('/');
+            }
+            if (host != null) {
+                result.append(host.getName()).append('/');
+            }
+            file = new File (getConfigBase(), result.toString());
         }
-        if (host != null) {
-            result.append(host.getName()).append('/');
+        try {
+            return file.getCanonicalFile();
+        } catch (IOException e) {
+            return file;
         }
-        result.append(resourceName);
-        return result.toString();
     }
 
-
     /**
      * Scan the web.xml files that apply to the web application and merge them
      * using the rules defined in the spec. For the global web.xml files,
@@ -1644,23 +1653,15 @@ public class ContextConfig implements Li
      * it.
      */
     protected InputSource getHostWebXmlSource() {
-        String resourceName = getHostConfigPath(Constants.HostWebXml);
-
-        // In an embedded environment, configBase might not be set
-        File configBase = getConfigBase();
-        if (configBase == null) {
-            return null;
-        }
-
         String basePath = null;
         try {
-            basePath = configBase.getCanonicalPath();
+            basePath = getHostConfigBase().getCanonicalPath();
         } catch (IOException e) {
             log.error(sm.getString("contextConfig.baseError"), e);
             return null;
         }
 
-        return getWebXmlSource(resourceName, basePath);
+        return getWebXmlSource(Constants.HostWebXml, basePath);
     }
 
     /**



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