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/17 15:16:34 UTC

svn commit: r1483786 - /tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java

Author: markt
Date: Fri May 17 13:16:34 2013
New Revision: 1483786

URL: http://svn.apache.org/r1483786
Log:
Add redeployResources entries for files that don't exist with a last modified time of zero to detect the addition a WAR or XML when just a DIR exists

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=1483786&r1=1483785&r2=1483786&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Fri May 17 13:16:34 2013
@@ -1019,7 +1019,9 @@ public class HostConfig
 
         Context context = null;
         File xml = new File(dir, Constants.ApplicationContextXml);
-        File xmlCopy = null;
+        File xmlCopy =
+                new File(host.getConfigBaseFile(), cn.getBaseName() + ".xml");
+
 
         DeployedApplication deployedApp = new DeployedApplication(cn.getName(),
                 xml.exists() && deployXML && copyXML);
@@ -1041,7 +1043,6 @@ public class HostConfig
                     }
                 }
                 if (copyXML) {
-                    xmlCopy = new File(host.getConfigBaseFile(), cn.getBaseName() + ".xml");
                     InputStream is = null;
                     OutputStream os = null;
                     try {
@@ -1084,18 +1085,33 @@ public class HostConfig
             log.error(sm.getString("hostConfig.deployDir.error",
                     dir.getAbsolutePath()), t);
         } finally {
+            // Fake re-deploy resource to detect if a WAR is added at a later
+            // point
+            deployedApp.redeployResources.put(dir.getAbsolutePath() + ".war",
+                    Long.valueOf(0));
             deployedApp.redeployResources.put(dir.getAbsolutePath(),
                     Long.valueOf(dir.lastModified()));
             if (deployXML && xml.exists()) {
-                if (xmlCopy == null) {
+                if (copyXML) {
+                    deployedApp.redeployResources.put(
+                            xmlCopy.getAbsolutePath(),
+                            Long.valueOf(xmlCopy.lastModified()));
+                } else {
                     deployedApp.redeployResources.put(
                             xml.getAbsolutePath(),
                             Long.valueOf(xml.lastModified()));
-                } else {
+                    // Fake re-deploy resource to detect if a context.xml file is
+                    // added at a later point
                     deployedApp.redeployResources.put(
                             xmlCopy.getAbsolutePath(),
-                            Long.valueOf(xmlCopy.lastModified()));
+                            Long.valueOf(0));
                 }
+            } else {
+                // Fake re-deploy resource to detect if a context.xml file is
+                // added at a later point
+                deployedApp.redeployResources.put(
+                        xmlCopy.getAbsolutePath(),
+                        Long.valueOf(0));
             }
             addWatchedResources(deployedApp, dir.getAbsolutePath(), context);
             // Add the global redeploy resources (which are never deleted) at
@@ -1188,9 +1204,9 @@ public class HostConfig
             if (log.isDebugEnabled())
                 log.debug("Checking context[" + app.name +
                         "] redeploy resource " + resource);
-            if (resource.exists()) {
-                long lastModified =
+            long lastModified =
                     app.redeployResources.get(resources[i]).longValue();
+            if (resource.exists() || lastModified == 0) {
                 if (resource.lastModified() > lastModified) {
                     if (resource.isDirectory()) {
                         // No action required for modified directory
@@ -1240,8 +1256,6 @@ public class HostConfig
                 if (resource.exists()) {
                     continue;
                 }
-                long lastModified =
-                    app.redeployResources.get(resources[i]).longValue();
                 if (lastModified == 0L) {
                     continue;
                 }



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