remm 2002/11/29 06:46:02 Modified: catalina/src/share/org/apache/catalina/startup HostConfig.java Log: - Add reloading for the context XML files. - I plan to port the last two patches to the 4.1 branch. Please let me know if it's not ok. Revision Changes Path 1.5 +52 -15 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- HostConfig.java 11 Sep 2002 13:08:19 -0000 1.4 +++ HostConfig.java 29 Nov 2002 14:46:02 -0000 1.5 @@ -202,16 +202,24 @@ */ private HashMap webXmlLastModified = new HashMap(); + + /** + * Last modified dates of the Context xml files of the contexts, keyed by + * context name. + */ + private HashMap contextXmlLastModified = new HashMap(); + + /** * Attribute value used to turn on/off XML validation */ - private boolean xmlValidation = false; + private boolean xmlValidation = false; /** * Attribute value used to turn on/off XML namespace awarenes. */ - private boolean xmlNamespaceAware = false; + private boolean xmlNamespaceAware = false; // ------------------------------------------------------------- Properties @@ -638,7 +646,7 @@ /** * Check deployment descriptors last modified date. */ - protected void checkWebXmlLastModified() { + protected void checkContextLastModified() { if (!(host instanceof Deployer)) return; @@ -673,24 +681,53 @@ } else { if (lastModified.longValue() != newLastModified) { webXmlLastModified.remove(contextName); - ((Lifecycle) context).stop(); - // Note: If the context was already stopped, a - // Lifecycle exception will be thrown, and the context - // won't be restarted - ((Lifecycle) context).start(); + restartContext(context); } } - } catch (LifecycleException e) { - ; // Ignore } catch (NamingException e) { ; // Ignore } + Long lastModified = (Long) contextXmlLastModified.get(contextName); + String configFileName = context.getConfigFile(); + if (configFileName != null) { + File configFile = new File(configFileName); + if (!configFile.isAbsolute()) { + configFile = new File(System.getProperty("catalina.base"), + configFile.getPath()); + } + long newLastModified = configFile.lastModified(); + if (lastModified == null) { + contextXmlLastModified.put + (contextName, new Long(newLastModified)); + } else { + if (lastModified.longValue() != newLastModified) { + contextXmlLastModified.remove(contextName); + restartContext(context); + } + } + } + } } + protected boolean restartContext(Context context) { + log.info("restartContext(" + context.getName() + ")"); + boolean result = true; + try { + ((Lifecycle) context).stop(); + // Note: If the context was already stopped, a + // Lifecycle exception will be thrown, and the context + // won't be restarted + ((Lifecycle) context).start(); + } catch (LifecycleException e) { + result = false; + } + return result; + } + /** * Expand the WAR file found at the specified URL into an unpacked @@ -1063,7 +1100,7 @@ deployApps(); // Check for web.xml modification - checkWebXmlLastModified(); + checkContextLastModified(); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>