Author: kfujino
Date: Tue May 22 09:27:00 2012
New Revision: 1341370
URL: http://svn.apache.org/viewvc?rev=1341370&view=rev
Log:
Enable host's xmlBase attribute in ContextConfig.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1341370&r1=1341369&r2=1341370&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
Tue May 22 09:27:00 2012
@@ -559,9 +559,8 @@ public class ContextConfig implements Li
"contextConfig.badUrl", defaultContextFile), e);
}
}
-
- File hostContextFile = new File(getConfigBase(),
- getHostConfigPath(Constants.HostContextXml));
+
+ File hostContextFile = new File(getHostConfigBase(),
Constants.HostContextXml);
if (hostContextFile.exists()) {
try {
URL hostContextUrl = hostContextFile.toURI().toURL();
@@ -1152,30 +1151,43 @@ 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;
- if (container instanceof Engine)
- engine = container;
+ if (container instanceof Host) {
+ host = (Host)container;
+ }
+ if (container instanceof Engine) {
+ 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(new
File(System.getProperty(Globals.CATALINA_BASE_PROP)),
+ 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,
@@ -1686,22 +1698,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);
}
/**
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1341370&r1=1341369&r2=1341370&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue May 22 09:27:00 2012
@@ -112,6 +112,9 @@
<bug>53067</bug>: Ensure the WebSocket Servlet continues to work when
requests are wrapped. (markt)
</fix>
+ <fix>
+ Enable host's xmlBase attribute in ContextConfig. (kfujino)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]