Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 56648 invoked by uid 500); 20 Oct 2001 18:50:52 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: tomcat-dev@jakarta.apache.org Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 56639 invoked by uid 500); 20 Oct 2001 18:50:51 -0000 Delivered-To: apmail-jakarta-tomcat-4.0-cvs@apache.org Date: 20 Oct 2001 18:43:53 -0000 Message-ID: <20011020184353.70880.qmail@icarus.apache.org> From: remm@apache.org To: jakarta-tomcat-4.0-cvs@apache.org Subject: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup HostConfig.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N remm 01/10/20 11:43:53 Modified: catalina/src/share/org/apache/catalina/startup HostConfig.java Log: - New attempt to fix the CRLF problems. - Add webapp auto deploy. For example, a WAR dropped in the appBase directory of a host will be automatically deployed. - Add web.xml tracking. If web.xml is modified, the context will be stopped and then restarted. That only happens with reloadable contexts. - All is done by a background thread very similar to the background thread the class reloading uses. There is one thread associated with each host. At the moment, the thread will always be created, but this could be made optional by adding a new flag to the host (like autoDeploy). Revision Changes Path 1.11 +620 -1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java Index: HostConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- HostConfig.java 2001/10/19 23:09:00 1.10 +++ HostConfig.java 2001/10/20 18:43:52 1.11 @@ -1 +1,620 @@ -/* * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v 1.10 2001/10/19 23:09:00 remm Exp $ * $Revision: 1.10 $ * $Date: 2001/10/19 23:09:00 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.catalina.startup; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; import org.apache.catalina.Context; import org.apache.catalina.Deployer; import org.apache.catalina.Host; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; import org.apache.catalina.Logger; import org.apache.catalina.core.StandardHost; import org.apache.catalina.util.StringManager; /** * Startup event listener for a Host that configures the properties * of that Host, and the associated defined contexts. * * @author Craig R. McClanahan * @version $Revision: 1.10 $ $Date: 2001/10/19 23:09:00 $ */ public final class HostConfig implements LifecycleListener { // ----------------------------------------------------- Instance Variables /** * The Java class name of the Context configuration class we should use. */ private String configClass = "org.apache.catalina.startup.ContextConfig"; /** * The Java class name of the Context implementation we should use. */ private String contextClass = "org.apache.catalina.core.StandardContext"; /** * The debugging detail level for this component. */ private int debug = 0; /** * The Host we are associated with. */ private Host host = null; /** * The string resources for this package. */ private static final StringManager sm = StringManager.getManager(Constants.Package); // ------------------------------------------------------------- Properties /** * Return the Context configuration class name. */ public String getConfigClass() { return (this.configClass); } /** * Set the Context configuration class name. * * @param configClass The new Context configuration class name. */ public void setConfigClass(String configClass) { this.configClass = configClass; } /** * Return the Context implementation class name. */ public String getContextClass() { return (this.contextClass); } /** * Set the Context implementation class name. * * @param contextClass The new Context implementation class name. */ public void setContextClass(String contextClass) { this.contextClass = contextClass; } /** * Return the debugging detail level for this component. */ public int getDebug() { return (this.debug); } /** * Set the debugging detail level for this component. * * @param debug The new debugging detail level */ public void setDebug(int debug) { this.debug = debug; } // --------------------------------------------------------- Public Methods /** * Process the START event for an associated Host. * * @param event The lifecycle event that has occurred */ public void lifecycleEvent(LifecycleEvent event) { // Identify the host we are associated with try { host = (Host) event.getLifecycle(); if (host instanceof StandardHost) { int hostDebug = ((StandardHost) host).getDebug(); if (hostDebug > this.debug) this.debug = hostDebug; } } catch (ClassCastException e) { log(sm.getString("hostConfig.cce", event.getLifecycle()), e); return; } // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); } // -------------------------------------------------------- Private Methods /** * Return a File object representing the "application root" directory * for our associated Host. */ private File appBase() { File file = new File(host.getAppBase()); if (!file.isAbsolute()) file = new File(System.getProperty("catalina.base"), host.getAppBase()); return (file); } /** * Deploy applications for any directories or WAR files that are found * in our "application root" directory. */ private void deployApps() { if (!(host instanceof Deployer)) return; if (debug >= 1) log(sm.getString("hostConfig.deploying")); File appBase = appBase(); if (!appBase.exists() || !appBase.isDirectory()) return; String files[] = appBase.list(); for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) continue; if (files[i].equalsIgnoreCase("WEB-INF")) continue; File dir = new File(appBase, files[i]); if (dir.isDirectory()) { // Make sure there is an application configuration directory File webInf = new File(dir, "/WEB-INF"); if (!webInf.exists() || !webInf.isDirectory() || !webInf.canRead()) continue; // Calculate the context path and make sure it is unique String contextPath = "/" + files[i]; if (files[i].equals("ROOT")) contextPath = ""; if (host.findChild(contextPath) != null) continue; // Deploy the application in this directory if (debug >= 1) log(sm.getString("hostConfig.deployDir", files[i])); try { URL url = new URL("file", null, dir.getCanonicalPath()); ((Deployer) host).install(contextPath, url); } catch (Throwable t) { log(sm.getString("hostConfig.deployDir.error", files[i]), t); } } else if (files[i].toLowerCase().endsWith(".war")) { // Calculate the context path and make sure it is unique String contextPath = "/" + files[i]; int period = contextPath.lastIndexOf("."); if (period >= 0) contextPath = contextPath.substring(0, period); if (contextPath.equals("/ROOT")) contextPath = ""; if (host.findChild(contextPath) != null) continue; // Deploy the application in this WAR file if (debug >= 1) log(sm.getString("hostConfig.deployJar", files[i])); try { URL url = new URL("file", null, dir.getCanonicalPath()); url = new URL("jar:" + url.toString() + "!/"); ((Deployer) host).install(contextPath, url); } catch (Throwable t) { log(sm.getString("hostConfig.deployJar.error", files[i]), t); } } } } /** * Log a message on the Logger associated with our Host (if any) * * @param message Message to be logged */ private void log(String message) { Logger logger = null; if (host != null) logger = host.getLogger(); if (logger != null) logger.log("HostConfig[" + host.getName() + "]: " + message); else System.out.println("HostConfig[" + host.getName() + "]: " + message); } /** * Log a message on the Logger associated with our Host (if any) * * @param message Message to be logged * @param throwable Associated exception */ private void log(String message, Throwable throwable) { Logger logger = null; if (host != null) logger = host.getLogger(); if (logger != null) logger.log("HostConfig[" + host.getName() + "] " + message, throwable); else { System.out.println("HostConfig[" + host.getName() + "]: " + message); System.out.println("" + throwable); throwable.printStackTrace(System.out); } } /** * Process a "start" event for this Host. */ private void start() { if (debug >= 1) log(sm.getString("hostConfig.start")); deployApps(); } /** * Process a "stop" event for this Host. */ private void stop() { if (debug >= 1) log(sm.getString("hostConfig.stop")); undeployApps(); } /** * Undeploy all deployed applications. */ private void undeployApps() { if (!(host instanceof Deployer)) return; if (debug >= 1) log(sm.getString("hostConfig.undeploying")); String contextPaths[] = ((Deployer) host).findDeployedApps(); for (int i = 0; i < contextPaths.length; i++) { if (debug >= 1) log(sm.getString("hostConfig.undeploy", contextPaths[i])); try { ((Deployer) host).remove(contextPaths[i]); } catch (Throwable t) { log(sm.getString("hostConfig.undeploy.error", contextPaths[i]), t); } } } } \ No newline at end of file +/* + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v 1.11 2001/10/20 18:43:52 remm Exp $ + * $Revision: 1.11 $ + * $Date: 2001/10/20 18:43:52 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * [Additional notices, if required by prior licensing conditions] + * + */ + + +package org.apache.catalina.startup; + + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import org.apache.naming.resources.ResourceAttributes; +import org.apache.catalina.Context; +import org.apache.catalina.Deployer; +import org.apache.catalina.Host; +import org.apache.catalina.Lifecycle; +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.Logger; +import org.apache.catalina.core.StandardHost; +import org.apache.catalina.util.StringManager; + + +/** + * Startup event listener for a Host that configures the properties + * of that Host, and the associated defined contexts. + * + * @author Craig R. McClanahan + * @author Remy Maucherat + * @version $Revision: 1.11 $ $Date: 2001/10/20 18:43:52 $ + */ + +public class HostConfig + implements LifecycleListener, Runnable { + + + // ----------------------------------------------------- Instance Variables + + + /** + * The Java class name of the Context configuration class we should use. + */ + protected String configClass = "org.apache.catalina.startup.ContextConfig"; + + + /** + * The Java class name of the Context implementation we should use. + */ + protected String contextClass = "org.apache.catalina.core.StandardContext"; + + + /** + * The debugging detail level for this component. + */ + protected int debug = 0; + + + /** + * The Host we are associated with. + */ + protected Host host = null; + + + /** + * The string resources for this package. + */ + protected static final StringManager sm = + StringManager.getManager(Constants.Package); + + + /** + * The number of seconds between checks for web app deployment. + */ + private int checkInterval = 15; + + + /** + * The background thread. + */ + private Thread thread = null; + + + /** + * The background thread completion semaphore. + */ + private boolean threadDone = false; + + + /** + * Name to register for the background thread. + */ + private String threadName = "HostConfig"; + + + /** + * Last modified dates of the web.xml files of the contexts, keyed by + * context name. + */ + private HashMap webXmlLastModified = new HashMap(); + + + // ------------------------------------------------------------- Properties + + + /** + * Return the Context configuration class name. + */ + public String getConfigClass() { + + return (this.configClass); + + } + + + /** + * Set the Context configuration class name. + * + * @param configClass The new Context configuration class name. + */ + public void setConfigClass(String configClass) { + + this.configClass = configClass; + + } + + + /** + * Return the Context implementation class name. + */ + public String getContextClass() { + + return (this.contextClass); + + } + + + /** + * Set the Context implementation class name. + * + * @param contextClass The new Context implementation class name. + */ + public void setContextClass(String contextClass) { + + this.contextClass = contextClass; + + } + + + /** + * Return the debugging detail level for this component. + */ + public int getDebug() { + + return (this.debug); + + } + + + /** + * Set the debugging detail level for this component. + * + * @param debug The new debugging detail level + */ + public void setDebug(int debug) { + + this.debug = debug; + + } + + + // --------------------------------------------------------- Public Methods + + + /** + * Process the START event for an associated Host. + * + * @param event The lifecycle event that has occurred + */ + public void lifecycleEvent(LifecycleEvent event) { + + // Identify the host we are associated with + try { + host = (Host) event.getLifecycle(); + if (host instanceof StandardHost) { + int hostDebug = ((StandardHost) host).getDebug(); + if (hostDebug > this.debug) + this.debug = hostDebug; + } + } catch (ClassCastException e) { + log(sm.getString("hostConfig.cce", event.getLifecycle()), e); + return; + } + + // Process the event that has occurred + if (event.getType().equals(Lifecycle.START_EVENT)) + start(); + else if (event.getType().equals(Lifecycle.STOP_EVENT)) + stop(); + + } + + + // ------------------------------------------------------ Protected Methods + + + /** + * Return a File object representing the "application root" directory + * for our associated Host. + */ + protected File appBase() { + + File file = new File(host.getAppBase()); + if (!file.isAbsolute()) + file = new File(System.getProperty("catalina.base"), + host.getAppBase()); + return (file); + + } + + + /** + * Deploy applications for any directories or WAR files that are found + * in our "application root" directory. + */ + protected void deployApps() { + + if (!(host instanceof Deployer)) + return; + if (debug >= 1) + log(sm.getString("hostConfig.deploying")); + + File appBase = appBase(); + if (!appBase.exists() || !appBase.isDirectory()) + return; + String files[] = appBase.list(); + + for (int i = 0; i < files.length; i++) { + + if (files[i].equalsIgnoreCase("META-INF")) + continue; + if (files[i].equalsIgnoreCase("WEB-INF")) + continue; + File dir = new File(appBase, files[i]); + if (dir.isDirectory()) { + + // Make sure there is an application configuration directory + File webInf = new File(dir, "/WEB-INF"); + if (!webInf.exists() || !webInf.isDirectory() || + !webInf.canRead()) + continue; + + // Calculate the context path and make sure it is unique + String contextPath = "/" + files[i]; + if (files[i].equals("ROOT")) + contextPath = ""; + if (host.findChild(contextPath) != null) + continue; + + // Deploy the application in this directory + if (debug >= 1) + log(sm.getString("hostConfig.deployDir", files[i])); + try { + URL url = new URL("file", null, dir.getCanonicalPath()); + ((Deployer) host).install(contextPath, url); + } catch (Throwable t) { + log(sm.getString("hostConfig.deployDir.error", files[i]), + t); + } + + } else if (files[i].toLowerCase().endsWith(".war")) { + + // Calculate the context path and make sure it is unique + String contextPath = "/" + files[i]; + int period = contextPath.lastIndexOf("."); + if (period >= 0) + contextPath = contextPath.substring(0, period); + if (contextPath.equals("/ROOT")) + contextPath = ""; + if (host.findChild(contextPath) != null) + continue; + + // Deploy the application in this WAR file + if (debug >= 1) + log(sm.getString("hostConfig.deployJar", files[i])); + try { + URL url = new URL("file", null, dir.getCanonicalPath()); + url = new URL("jar:" + url.toString() + "!/"); + ((Deployer) host).install(contextPath, url); + } catch (Throwable t) { + log(sm.getString("hostConfig.deployJar.error", files[i]), + t); + } + + } + + } + + } + + + /** + * Check deployment descriptors last modified date. + */ + protected void checkWebXmlLastModified() { + + if (!(host instanceof Deployer)) + return; + + Deployer deployer = (Deployer) host; + + String[] contextNames = deployer.findDeployedApps(); + + for (int i = 0; i < contextNames.length; i++) { + + String contextName = contextNames[i]; + Context context = deployer.findDeployedApp(contextName); + + if (!context.getReloadable()) + continue; + + if (!(context instanceof Lifecycle)) + continue; + + try { + DirContext resources = context.getResources(); + ResourceAttributes webXmlAttributes = + (ResourceAttributes) + resources.getAttributes("/WEB-INF/web.xml"); + long newLastModified = webXmlAttributes.getLastModified(); + Long lastModified = (Long) webXmlLastModified.get(contextName); + if (lastModified == null) { + webXmlLastModified.put + (contextName, new Long(newLastModified)); + } 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(); + } + } + } catch (LifecycleException e) { + ; // Ignore + } catch (NamingException e) { + ; // Ignore + } + + } + + } + + + + /** + * Log a message on the Logger associated with our Host (if any) + * + * @param message Message to be logged + */ + protected void log(String message) { + + Logger logger = null; + if (host != null) + logger = host.getLogger(); + if (logger != null) + logger.log("HostConfig[" + host.getName() + "]: " + message); + else + System.out.println("HostConfig[" + host.getName() + "]: " + + message); + + } + + + /** + * Log a message on the Logger associated with our Host (if any) + * + * @param message Message to be logged + * @param throwable Associated exception + */ + protected void log(String message, Throwable throwable) { + + Logger logger = null; + if (host != null) + logger = host.getLogger(); + if (logger != null) + logger.log("HostConfig[" + host.getName() + "] " + + message, throwable); + else { + System.out.println("HostConfig[" + host.getName() + "]: " + + message); + System.out.println("" + throwable); + throwable.printStackTrace(System.out); + } + + } + + + /** + * Process a "start" event for this Host. + */ + protected void start() { + + if (debug >= 1) + log(sm.getString("hostConfig.start")); + + threadStart(); + + } + + + /** + * Process a "stop" event for this Host. + */ + protected void stop() { + + if (debug >= 1) + log(sm.getString("hostConfig.stop")); + + threadStop(); + + undeployApps(); + + } + + + /** + * Undeploy all deployed applications. + */ + protected void undeployApps() { + + if (!(host instanceof Deployer)) + return; + if (debug >= 1) + log(sm.getString("hostConfig.undeploying")); + + String contextPaths[] = ((Deployer) host).findDeployedApps(); + for (int i = 0; i < contextPaths.length; i++) { + if (debug >= 1) + log(sm.getString("hostConfig.undeploy", contextPaths[i])); + try { + ((Deployer) host).remove(contextPaths[i]); + } catch (Throwable t) { + log(sm.getString("hostConfig.undeploy.error", + contextPaths[i]), t); + } + } + + } + + + /** + * Start the background thread that will periodically check for + * session timeouts. + * + * @exception IllegalStateException if we should not be starting + * a background thread now + */ + protected void threadStart() { + + // Has the background thread already been started? + if (thread != null) + return; + + // Start the background thread + if (debug >= 1) + log(" Starting background thread"); + threadDone = false; + threadName = "HostConfig[" + host.getName() + "]"; + thread = new Thread(this, threadName); + thread.setDaemon(true); + thread.start(); + + } + + + /** + * Stop the background thread that is periodically checking for + * modified classes. + */ + protected void threadStop() { + + if (thread == null) + return; + + if (debug >= 1) + log(" Stopping background thread"); + threadDone = true; + thread.interrupt(); + try { + thread.join(); + } catch (InterruptedException e) { + ; + } + + thread = null; + + } + + + /** + * Sleep for the duration specified by the checkInterval + * property. + */ + protected void threadSleep() { + + try { + Thread.sleep(checkInterval * 1000L); + } catch (InterruptedException e) { + ; + } + + } + + + // ------------------------------------------------------ Background Thread + + + /** + * The background thread that checks for session timeouts and shutdown. + */ + public void run() { + + if (debug >= 1) + log("BACKGROUND THREAD Starting"); + + // Loop until the termination semaphore is set + while (!threadDone) { + + // Deploy apps + deployApps(); + + // Check for web.xml modification + checkWebXmlLastModified(); + + // Wait for our check interval + threadSleep(); + + } + + if (debug >= 1) + log("BACKGROUND THREAD Stopping"); + + } + + +}