You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/08/20 10:20:41 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session PersistentManagerBase.java

remm        2003/08/20 01:20:41

  Modified:    catalina/src/share/org/apache/catalina/session
                        PersistentManagerBase.java
  Log:
  - Similar to StoreBase, do not use a per component thread.
  
  Revision  Changes    Path
  1.10      +28 -158   jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java
  
  Index: PersistentManagerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PersistentManagerBase.java	19 Aug 2003 00:49:58 -0000	1.9
  +++ PersistentManagerBase.java	20 Aug 2003 08:20:41 -0000	1.10
  @@ -98,8 +98,8 @@
   
   public abstract class PersistentManagerBase
       extends ManagerBase
  -    implements Lifecycle, PropertyChangeListener, Runnable
  - {
  +    implements Lifecycle, PropertyChangeListener {
  +
       private static Log log = LogFactory.getLog(PersistentManagerBase.class);
   
       // ---------------------------------------------------- Security Classes
  @@ -174,12 +174,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 = "PersistentManagerBase/1.0";
  @@ -210,24 +204,6 @@
   
   
       /**
  -     * The background thread.
  -     */
  -    private Thread thread = null;
  -
  -
  -    /**
  -     * The background thread completion semaphore.
  -     */
  -    protected boolean threadDone = false;
  -
  -
  -    /**
  -     * Name to register for the background thread.
  -     */
  -    private String threadName = "PersistentManagerBase";
  -
  -
  -    /**
        * Store object which will manage the Session store.
        */
       private Store store = null;
  @@ -266,33 +242,6 @@
   
   
       /**
  -     * 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));
  -
  -    }
  -
  -
  -
  -    /**
        * Indicates how many seconds old a session can get, after its last
        * use in a request, before it should be backed up to the store. -1
        * means sessions are not backed up.
  @@ -602,6 +551,27 @@
   
   
       /**
  +     * Invalidate all sessions that have expired.
  +     */
  +    public void processExpires() {
  +
  +        if (!started)
  +            return;
  +
  +        long timeNow = System.currentTimeMillis();
  +        Session sessions[] = findSessions();
  +
  +        for (int i = 0; i < sessions.length; i++) {
  +            StandardSession session = (StandardSession) sessions[i];
  +            if (!session.isValid()) {
  +                session.expire();
  +	    }
  +        }
  +
  +    }
  +
  +
  +    /**
        * Called by the background thread after active sessions have
        * been checked for expiration, to allow sessions to be
        * swapped out, backed up, etc.
  @@ -981,9 +951,6 @@
           else if (store instanceof Lifecycle)
               ((Lifecycle)store).start();
   
  -        // Start the background reaper thread
  -        threadStart();
  -
       }
   
   
  @@ -1009,9 +976,6 @@
           lifecycle.fireLifecycleEvent(STOP_EVENT, null);
           setStarted(false);
   
  -        // Stop the background reaper thread
  -        threadStop();
  -
           if (getStore() != null && saveOnRestart) {
               unload();
           } else {
  @@ -1033,7 +997,7 @@
   
           if( initialized )
               destroy();
  -        
  +
       }
   
   
  @@ -1070,27 +1034,6 @@
   
   
       /**
  -     * Invalidate all sessions that have expired.
  -     */
  -    protected void processExpires() {
  -
  -        if (!started)
  -            return;
  -
  -        long timeNow = System.currentTimeMillis();
  -        Session sessions[] = findSessions();
  -
  -        for (int i = 0; i < sessions.length; i++) {
  -            StandardSession session = (StandardSession) sessions[i];
  -            if (!session.isValid()) {
  -                session.expire();
  -	    }
  -        }
  -
  -    }
  -
  -
  -    /**
        * Swap idle sessions out to Store if they are idle too long.
        */
       protected void processMaxIdleSwaps() {
  @@ -1202,79 +1145,6 @@
                       }
                   }
               }
  -        }
  -
  -    }
  -
  -
  -    /**
  -     * Sleep for the duration specified by the <code>checkInterval</code>
  -     * property.
  -     */
  -    protected void threadSleep() {
  -
  -        try {
  -            Thread.sleep(checkInterval * 1000L);
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -
  -    }
  -
  -
  -    /**
  -     * Start the background thread that will periodically check for
  -     * session timeouts.
  -     */
  -    protected void threadStart() {
  -
  -        if (thread != null)
  -            return;
  -
  -        threadDone = false;
  -        threadName = "StandardManager[" + container.getName() + "]";
  -        thread = new Thread(this, threadName);
  -        thread.setDaemon(true);
  -        thread.start();
  -
  -    }
  -
  -
  -    /**
  -     * Stop the background thread that is periodically checking for
  -     * session timeouts.
  -     */
  -    protected 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();
  -            processPersistenceChecks();
           }
   
       }