You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/05/16 15:40:31 UTC
svn commit: r1483359 -
/tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java
Author: markt
Date: Thu May 16 13:40:31 2013
New Revision: 1483359
URL: http://svn.apache.org/r1483359
Log:
Revert r1482834
Modified:
tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=1483359&r1=1483358&r2=1483359&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Thu May 16 13:40:31 2013
@@ -543,10 +543,7 @@ public class HostConfig
Context context = null;
boolean isExternalWar = false;
boolean isExternal = false;
-
- // context.xml is always first
- deployedApp.redeployResources.put(contextXml.getAbsolutePath(),
- Long.valueOf(contextXml.lastModified()));
+ File expandedDocBase = null;
try (FileInputStream fis = new FileInputStream(contextXml)) {
synchronized (digester) {
@@ -566,32 +563,30 @@ public class HostConfig
Class<?> clazz = Class.forName(host.getConfigClass());
LifecycleListener listener =
- (LifecycleListener) clazz.newInstance();
+ (LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
context.setConfigFile(contextXml.toURI().toURL());
context.setName(cn.getName());
context.setPath(cn.getPath());
context.setWebappVersion(cn.getVersion());
-
- // Validate the docBase
+ // Add the associated docBase to the redeployed list if it's a WAR
if (context.getDocBase() != null) {
File docBase = new File(context.getDocBase());
if (!docBase.isAbsolute()) {
docBase = new File(host.getAppBaseFile(), context.getDocBase());
}
+ // If external docBase, register .xml as redeploy first
if (!docBase.getCanonicalPath().startsWith(
host.getAppBaseFile().getAbsolutePath() + File.separator)) {
isExternal = true;
- if (docBase.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
- isExternalWar = true;
- }
- // Valid external docBase - add it to redeploy list
+ deployedApp.redeployResources.put(
+ contextXml.getAbsolutePath(),
+ Long.valueOf(contextXml.lastModified()));
deployedApp.redeployResources.put(docBase.getAbsolutePath(),
Long.valueOf(docBase.lastModified()));
- if (!isExternalWar) {
- addWatchedResources(deployedApp,
- docBase.getAbsolutePath(), context);
+ if (docBase.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
+ isExternalWar = true;
}
} else {
log.warn(sm.getString("hostConfig.deployDescriptor.localDocBaseSpecified",
@@ -608,53 +603,49 @@ public class HostConfig
contextXml.getAbsolutePath()), t);
} finally {
// Get paths for WAR and expanded WAR in appBase
- File expandedDocBase = null;
- if (context.getDocBase() == null) {
- // default to appBase dir + name
- expandedDocBase =
- new File(host.getAppBaseFile(), cn.getBaseName());
- } else {
+
+ // default to appBase dir + name
+ expandedDocBase = new File(host.getAppBaseFile(), cn.getBaseName());
+ if (context.getDocBase() != null) {
// first assume docBase is absolute
expandedDocBase = new File(context.getDocBase());
if (!expandedDocBase.isAbsolute()) {
- // if docBase specified and relative, it must be relative to
- // appBase
+ // if docBase specified and relative, it must be relative to appBase
expandedDocBase = new File(host.getAppBaseFile(), context.getDocBase());
}
}
- File warDocBase =
- new File(expandedDocBase.getAbsolutePath() + ".war");
-
- if (isExternalWar && warDocBase.exists()) {
- // TODO log warning
- }
// Add the eventual unpacked WAR and all the resources which will be
// watched inside it
- if (isExternalWar) {
- if (unpackWARs) {
- deployedApp.redeployResources.put(
- expandedDocBase.getAbsolutePath(),
- Long.valueOf(expandedDocBase.lastModified()));
- addWatchedResources(deployedApp,
- expandedDocBase.getAbsolutePath(), context);
- }
- } else if (!isExternal) {
+ if (isExternalWar && unpackWARs) {
+ deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
+ Long.valueOf(expandedDocBase.lastModified()));
+ deployedApp.redeployResources.put(contextXml.getAbsolutePath(),
+ Long.valueOf(contextXml.lastModified()));
+ addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context);
+ } else {
// Find an existing matching war and expanded folder
- if (warDocBase.exists()) {
- deployedApp.redeployResources.put(
- warDocBase.getAbsolutePath(),
- Long.valueOf(warDocBase.lastModified()));
+ if (!isExternal) {
+ File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war");
+ if (warDocBase.exists()) {
+ deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
+ Long.valueOf(warDocBase.lastModified()));
+ }
}
if (expandedDocBase.exists()) {
- deployedApp.redeployResources.put(
- expandedDocBase.getAbsolutePath(),
+ deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
Long.valueOf(expandedDocBase.lastModified()));
addWatchedResources(deployedApp,
expandedDocBase.getAbsolutePath(), context);
} else {
addWatchedResources(deployedApp, null, context);
}
+ // Add the context XML to the list of files which should trigger a redeployment
+ if (!isExternal) {
+ deployedApp.redeployResources.put(
+ contextXml.getAbsolutePath(),
+ Long.valueOf(contextXml.lastModified()));
+ }
}
// Add the global redeploy resources (which are never deleted) at
// the end so they don't interfere with the deletion process
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org