remm 2003/06/24 16:42:34
Modified: catalina/src/share/org/apache/catalina/startup
HostConfig.java
Log:
- Refactor configBase and appBase lookup.
- Properly remove a context when its context file is updated, so that redeployment
succeeds.
- Don't do anything for config files outside of the configBase (at least for now).
Revision Changes Path
1.17 +50 -21
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java
Index: HostConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- HostConfig.java 24 Jun 2003 22:37:05 -0000 1.16
+++ HostConfig.java 24 Jun 2003 23:42:34 -0000 1.17
@@ -118,6 +118,18 @@
/**
+ * App base.
+ */
+ private File appBase = null;
+
+
+ /**
+ * Config base.
+ */
+ private File configBase = null;
+
+
+ /**
* The Java class name of the Context configuration class we should use.
*/
protected String configClass = "org.apache.catalina.startup.ContextConfig";
@@ -400,11 +412,20 @@
*/
protected File appBase() {
+ if (appBase != null) {
+ return appBase;
+ }
+
File file = new File(host.getAppBase());
if (!file.isAbsolute())
file = new File(System.getProperty("catalina.base"),
host.getAppBase());
- return (file);
+ try {
+ appBase = file.getCanonicalFile();
+ } catch (IOException e) {
+ appBase = file;
+ }
+ return (appBase);
}
@@ -421,7 +442,12 @@
file = new File(file, parent.getName());
}
file = new File(file, host.getName());
- return (file);
+ try {
+ configBase = file.getCanonicalFile();
+ } catch (IOException e) {
+ configBase = file;
+ }
+ return (configBase);
}
@@ -685,6 +711,7 @@
}
Long lastModified = (Long) contextXmlLastModified.get(contextName);
+ String configBase = configBase().getPath();
String configFileName = context.getConfigFile();
if (configFileName != null) {
File configFile = new File(configFileName);
@@ -699,23 +726,22 @@
} else {
if (lastModified.longValue() != newLastModified) {
contextXmlLastModified.remove(contextName);
- String fileName = contextName;
- if (fileName.equals("")) {
- fileName = "ROOT.xml";
- } else {
- fileName = fileName + ".war";
- }
- try {
- deployed.remove(fileName);
- if (host.findChild(contextName) != null) {
- ((Deployer) host).remove(contextName);
+ String fileName = configFileName;
+ if (fileName.startsWith(configBase)) {
+ fileName =
+ fileName.substring(configBase.length() + 1);
+ try {
+ deployed.remove(fileName);
+ if (host.findChild(contextName) != null) {
+ ((Deployer) host).remove(contextName);
+ }
+ } catch (Throwable t) {
+ log.error(sm.getString
+ ("hostConfig.undeployJar.error",
+ fileName), t);
}
- } catch (Throwable t) {
- log.error(sm.getString
- ("hostConfig.undeployJar.error",
- fileName), t);
+ deployApps();
}
- deployApps();
}
}
}
@@ -906,6 +932,9 @@
log.debug(sm.getString("hostConfig.stop"));
undeployApps();
+
+ appBase = null;
+ configBase = null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]