tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java
Date Thu, 22 May 2003 23:05:37 GMT
remm        2003/05/22 16:05:37

  Modified:    catalina/src/share/org/apache/catalina/startup
                        HostConfig.java
  Log:
  - Refactor the host deployer, session manager, webapp reloading threads
    into one (potentially) thread at the engine level.
  - The thread code is in StandardEngine, but can be refactored into
    StandardServer, in case we want to be able to have one thread for the whole
    server. The main adavantage of putting the code in container is that additional
    threads can be associated to branches of the container tree (ex: associate
    one thread per host, one thread for a specific context, etc ...).
  - The container's CL (if present) will be set as the context classloader before
    invoking the execute method, and will be restored afterwards.
  - I couldn't come up with good neams for the new field and the thread name.
    Can you help ?
  - By default, the engine will have a thread with a 10s delay.
  
  Revision  Changes    Path
  1.10      +12 -119   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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HostConfig.java	17 Apr 2003 19:44:59 -0000	1.9
  +++ HostConfig.java	22 May 2003 23:05:36 -0000	1.10
  @@ -107,7 +107,7 @@
    */
   
   public class HostConfig
  -    implements LifecycleListener, Runnable {
  +    implements LifecycleListener {
       
       private static org.apache.commons.logging.Log log=
            org.apache.commons.logging.LogFactory.getLog( HostConfig.class );
  @@ -154,12 +154,6 @@
   
   
       /**
  -     * The number of seconds between checks for web app deployment.
  -     */
  -    private int checkInterval = 15;
  -
  -
  -    /**
        * Should we deploy XML Context config files?
        */
       private boolean deployXML = false;
  @@ -173,24 +167,6 @@
   
   
       /**
  -     * 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";
  -
  -
  -    /**
        * Should we unpack WAR files when auto-deploying applications in the
        * <code>appBase</code> directory?
        */
  @@ -395,6 +371,7 @@
           this.xmlNamespaceAware=xmlNamespaceAware;
       }    
   
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -405,6 +382,9 @@
        */
       public void lifecycleEvent(LifecycleEvent event) {
   
  +        if (event.getType().equals("check"))
  +            check();
  +
           // Identify the host we are associated with
           try {
               host = (Host) event.getLifecycle();
  @@ -835,10 +815,6 @@
               deployApps();
           }
   
  -        if (isLiveDeploy()) {
  -            threadStart();
  -        }
  -
       }
   
   
  @@ -850,8 +826,6 @@
           if (log.isDebugEnabled())
               log.debug(sm.getString("hostConfig.stop"));
   
  -        threadStop();
  -
           undeployApps();
   
       }
  @@ -883,97 +857,16 @@
   
   
       /**
  -     * Start the background thread that will periodically check for
  -     * web application autoDeploy and changes to the web.xml config.
  -     *
  -     * @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 (log.isDebugEnabled())
  -            log.debug(" 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
  -     * for web application autoDeploy and changes to the web.xml config.
  +     * Deploy webapps.
        */
  -    protected void threadStop() {
  -
  -        if (thread == null)
  -            return;
  -
  -        if (log.isDebugEnabled())
  -            log.debug(" Stopping background thread");
  -        threadDone = true;
  -        thread.interrupt();
  -        try {
  -            thread.join();
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -
  -        thread = null;
  -
  -    }
  -
  -
  -    /**
  -     * Sleep for the duration specified by the <code>checkInterval</code>
  -     * property.
  -     */
  -    protected void threadSleep() {
  -
  -        try {
  -            Thread.sleep(checkInterval * 1000L);
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -
  -    }
  -
  -
  -    // ------------------------------------------------------ Background Thread
  -
  -
  -    /**
  -     * The background thread that checks for web application autoDeploy
  -     * and changes to the web.xml config.
  -     */
  -    public void run() {
  -
  -        if (log.isDebugEnabled())
  -            log.debug("BACKGROUND THREAD Starting");
  -
  -        // Loop until the termination semaphore is set
  -        while (!threadDone) {
  -
  -            // Wait for our check interval
  -            threadSleep();
  +    public void check() {
   
  +        if (host.getAutoDeploy()) {
               // Deploy apps if the Host allows auto deploying
               deployApps();
  -
               // Check for web.xml modification
               checkContextLastModified();
  -
           }
  -
  -        if (log.isDebugEnabled())
  -            log.debug("BACKGROUND THREAD Stopping");
   
       }
   
  
  
  

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


Mime
View raw message