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/19 19:11:49 UTC

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

remm        2003/08/19 10:11:49

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               catalina/src/share/org/apache/catalina/session
                        StoreBase.java
  Log:
  - Use the container provided background processing thread, rather than using one
    for each store.
  
  Revision  Changes    Path
  1.84      +14 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- StandardContext.java	12 Aug 2003 16:15:52 -0000	1.83
  +++ StandardContext.java	19 Aug 2003 17:11:49 -0000	1.84
  @@ -126,7 +126,9 @@
   import org.apache.catalina.deploy.SecurityCollection;
   import org.apache.catalina.deploy.SecurityConstraint;
   import org.apache.catalina.loader.WebappLoader;
  +import org.apache.catalina.session.PersistentManagerBase;
   import org.apache.catalina.session.StandardManager;
  +import org.apache.catalina.session.StoreBase;
   import org.apache.catalina.util.CharsetMapper;
   import org.apache.catalina.util.ExtensionValidator;
   import org.apache.catalina.util.RequestUtil;
  @@ -4300,9 +4302,17 @@
           if (!started)
               return;
   
  -        if ((getManager() != null) 
  -            && (getManager() instanceof StandardManager)) {
  -            ((StandardManager) getManager()).processExpires();
  +        if (getManager() != null) {
  +            if (getManager() instanceof StandardManager) {
  +                ((StandardManager) getManager()).processExpires();
  +            } else if (getManager() instanceof PersistentManagerBase) {
  +                PersistentManagerBase pManager = 
  +                    (PersistentManagerBase) getManager();
  +                if ((pManager.getStore() != null) 
  +                    && (pManager.getStore() instanceof StoreBase)) {
  +                    ((StoreBase) pManager.getStore()).processExpires();
  +                }
  +            }
           }
   
           if (getLoader() != null) {
  
  
  
  1.5       +9 -109    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StoreBase.java
  
  Index: StoreBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StoreBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StoreBase.java	19 Aug 2003 00:49:58 -0000	1.4
  +++ StoreBase.java	19 Aug 2003 17:11:49 -0000	1.5
  @@ -87,7 +87,7 @@
    */
   
   public abstract class StoreBase
  -    implements Lifecycle, Runnable, Store {
  +    implements Lifecycle, Store {
   
       // ----------------------------------------------------- Instance Variables
   
  @@ -97,31 +97,11 @@
       protected static String info = "StoreBase/1.0";
   
       /**
  -     * The interval (in seconds) between checks for expired sessions.
  -     */
  -    protected int checkInterval = 60;
  -
  -    /**
  -     * Name to register for the background thread.
  -     */
  -    protected String threadName = "StoreBase";
  -
  -    /**
        * Name to register for this Store, used for logging.
        */
       protected static String storeName = "StoreBase";
   
       /**
  -     * The background thread.
  -     */
  -    protected Thread thread = null;
  -
  -    /**
  -     * The background thread completion semaphore.
  -     */
  -    protected boolean threadDone = false;
  -
  -    /**
        * The debugging detail level for this component.
        */
       protected int debug = 0;
  @@ -160,12 +140,6 @@
           return(info);
       }
   
  -    /**
  -     * Return the thread name for this Store.
  -     */
  -    public String getThreadName() {
  -        return(threadName);
  -    }
   
       /**
        * Return the name for this Store, used for logging.
  @@ -174,6 +148,7 @@
           return(storeName);
       }
   
  +
       /**
        * Set the debugging detail level for this Store.
        *
  @@ -192,26 +167,6 @@
   
   
       /**
  -     * Set the check interval (in seconds) for this Store.
  -     *
  -     * @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));
  -    }
  -
  -    /**
  -     * Return the check interval (in seconds) for this Store.
  -     */
  -    public int getCheckInterval() {
  -        return(this.checkInterval);
  -    }
  -
  -    /**
        * Set the Manager with which this Store is associated.
        *
        * @param manager The newly associated Manager
  @@ -229,6 +184,7 @@
           return(this.manager);
       }
   
  +
       // --------------------------------------------------------- Public Methods
   
       /**
  @@ -287,7 +243,7 @@
        * the Session and remove it from the Store.
        *
        */
  -    protected void processExpires() {
  +    public void processExpires() {
           long timeNow = System.currentTimeMillis();
           String[] keys = null;
   
  @@ -358,16 +314,6 @@
   
       // --------------------------------------------------------- Thread Methods
   
  -    /**
  -     * The background thread that checks for session timeouts and shutdown.
  -     */
  -    public void run() {
  -        // Loop until the termination semaphore is set
  -        while (!threadDone) {
  -            threadSleep();
  -            processExpires();
  -        }
  -    }
   
       /**
        * Prepare for the beginning of active use of the public methods of this
  @@ -385,10 +331,9 @@
           lifecycle.fireLifecycleEvent(START_EVENT, null);
           started = true;
   
  -        // Start the background reaper thread
  -        threadStart();
       }
   
  +
       /**
        * Gracefully terminate the active use of the public methods of this
        * component.  This method should be the last one called on a given
  @@ -405,52 +350,7 @@
           lifecycle.fireLifecycleEvent(STOP_EVENT, null);
           started = false;
   
  -        // Stop the background reaper thread
  -        threadStop();
       }
   
  -    /**
  -     * Start the background thread that will periodically check for
  -     * session timeouts.
  -     */
  -    protected void threadStart() {
  -        if (thread != null)
  -            return;
  -
  -        threadDone = false;
  -        thread = new Thread(this, getThreadName());
  -        thread.setDaemon(true);
  -        thread.start();
  -    }
   
  -    /**
  -     * Sleep for the duration specified by the <code>checkInterval</code>
  -     * property.
  -     */
  -    protected void threadSleep() {
  -        try {
  -            Thread.sleep(checkInterval * 1000L);
  -        } catch (InterruptedException e) {
  -            ;
  -        }
  -    }
  -
  -    /**
  -     * 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;
  -    }
   }
  
  
  

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