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/session StandardManager.java
Date Fri, 23 May 2003 10:52:20 GMT
remm        2003/05/23 03:52:20

  Modified:    catalina/src/share/org/apache/catalina/session
                        StandardManager.java
  Log:
  - Apply missing commit (sorry).
  - 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.9       +10 -136   jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java
  
  Index: StandardManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardManager.java	25 Apr 2003 22:20:07 -0000	1.8
  +++ StandardManager.java	23 May 2003 10:52:20 -0000	1.9
  @@ -110,8 +110,7 @@
   
   public class StandardManager
       extends ManagerBase
  -    implements Lifecycle, PropertyChangeListener, Runnable 
  - {
  +    implements Lifecycle, PropertyChangeListener {
   
       // ---------------------------------------------------- Security Classes
       private class PrivilegedDoLoad
  @@ -144,12 +143,6 @@
   
   
       /**
  -     * The interval (in seconds) between checks for expired sessions.
  -     */
  -    private int checkInterval = 60;
  -
  -
  -    /**
        * The descriptive information about this implementation.
        */
       private static final String info = "StandardManager/1.0";
  @@ -189,54 +182,13 @@
        */
       private boolean started = false;
   
  -    /**
  -     * 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 = "StandardManager";
   
       int rejectedSessions=0;
       int expiredSessions=0;
       long processingTime=0;
   
  -    // ------------------------------------------------------------- Properties
  -
  -
  -    /**
  -     * Return the check interval (in seconds) for this Manager.
  -     */
  -    public int getCheckInterval() {
  -
  -        return (this.checkInterval);
  -
  -    }
  -
  -
  -    /**
  -     * Set the check interval (in seconds) for this Manager.
  -     *
  -     * @param checkInterval The new check interval
  -     */
  -    public void setCheckInterval(int checkInterval) {
  -
  -        int oldCheckInterval = this.checkInterval;
  -        this.checkInterval = checkInterval;
  -        support.firePropertyChange("checkInterval",
  -                                   new Integer(oldCheckInterval),
  -                                   new Integer(this.checkInterval));
   
  -    }
  +    // ------------------------------------------------------------- Properties
   
   
       /**
  @@ -742,9 +694,6 @@
               log.error(sm.getString("standardManager.managerLoad"), t);
           }
   
  -        // Start the background reaper thread
  -        threadStart();
  -
       }
   
   
  @@ -768,9 +717,6 @@
           lifecycle.fireLifecycleEvent(STOP_EVENT, null);
           started = false;
   
  -        // Stop the background reaper thread
  -        threadStop();
  -
           // Write out sessions
           try {
               unload();
  @@ -861,7 +807,7 @@
       /**
        * Invalidate all sessions that have expired.
        */
  -    private void processExpires() {
  +    public void processExpires() {
   
           long timeNow = System.currentTimeMillis();
           Session sessions[] = findSessions();
  @@ -880,87 +826,15 @@
                       expiredSessions++;
                       session.expire();
                   } catch (Throwable t) {
  -                    log.error(sm.getString("standardManager.expireException"), t);
  +                    log.error(sm.getString
  +                              ("standardManager.expireException"), t);
                   }
               }
           }
  -        long timeEnd=System.currentTimeMillis();
  +        long timeEnd = System.currentTimeMillis();
           processingTime += ( timeEnd - timeNow );
   
       }
   
   
  -    /**
  -     * Sleep for the duration specified by the <code>checkInterval</code>
  -     * property.
  -     */
  -    private void threadSleep() {
  -
  -        try {
  -            Thread.sleep(checkInterval * 1000L);
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -
  -    }
  -
  -
  -    /**
  -     * Start the background thread that will periodically check for
  -     * session timeouts.
  -     */
  -    private void threadStart() {
  -
  -        if (thread != null)
  -            return;
  -
  -        threadDone = false;
  -        threadName = "StandardManager[" + container.getName() + "]";
  -        thread = new Thread(this, threadName);
  -        thread.setDaemon(true);
  -        thread.setContextClassLoader(container.getLoader().getClassLoader());
  -        thread.start();
  -
  -    }
  -
  -
  -    /**
  -     * Stop the background thread that is periodically checking for
  -     * session timeouts.
  -     */
  -    private void threadStop() {
  -
  -        if (thread == null)
  -            return;
  -
  -        threadDone = true;
  -        thread.interrupt();
  -        try {
  -            thread.join();
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -
  -        thread = null;
  -
  -    }
  -
  -
  -    // ------------------------------------------------------ Background Thread
  -
  -
  -    /**
  -     * The background thread that checks for session timeouts and shutdown.
  -     */
  -    public void run() {
  -
  -        // Loop until the termination semaphore is set
  -        while (!threadDone) {
  -            threadSleep();
  -            processExpires();
  -        }
  -
  -    }
  -    
  -    
   }
  
  
  

---------------------------------------------------------------------
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