You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2001/04/27 09:55:47 UTC

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

kief        01/04/27 00:55:47

  Modified:    catalina/src/share/org/apache/catalina/session
                        PersistentManagerBase.java
  Log:
  - Overrode the remove() method to ensure sessions are also removed
  from the Store, mainly used to expire active sessions.
  
  - Changed unload() to use swapOut() rather than Session.expire().
  
  - Modified the swapOut() method to remove the session from active
  list and recycle the session object.
  
  Revision  Changes    Path
  1.3       +53 -15    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java
  
  Index: PersistentManagerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PersistentManagerBase.java	2001/04/17 17:07:03	1.2
  +++ PersistentManagerBase.java	2001/04/27 07:55:46	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java,v 1.2 2001/04/17 17:07:03 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/04/17 17:07:03 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/PersistentManagerBase.java,v 1.3 2001/04/27 07:55:46 kief Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/04/27 07:55:46 $
    *
    * ====================================================================
    *
  @@ -105,7 +105,7 @@
    * <code>stop()</code> methods of this class at the correct times.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2001/04/17 17:07:03 $
  + * @version $Revision: 1.3 $ $Date: 2001/04/27 07:55:46 $
    */
   
   public abstract class PersistentManagerBase
  @@ -125,7 +125,7 @@
       /**
        * The descriptive information about this implementation.
        */
  -    private static final String info = "MiddleManager/1.0";
  +    private static final String info = "PersistentManagerBase/1.0";
   
   
       /**
  @@ -167,7 +167,7 @@
       /**
        * Name to register for the background thread.
        */
  -    private String threadName = "MiddleManager";
  +    private String threadName = "PersistentManagerBase";
   
   
       /**
  @@ -408,16 +408,23 @@
        *  found during the reload
        * @exception IOException if an input/output error occurs
        */
  -    public void load() throws ClassNotFoundException, IOException {
  +    public void load() {
   
           // Initialize our internal data structures
  -//        recycled.clear();
  -//        sessions.clear();
  +        recycled.clear();
  +        sessions.clear();
   
           if (store == null)
               return;
   
  -        String[] ids = store.keys();
  +        String[] ids = null;
  +        try {
  +            ids = store.keys();
  +        } catch (IOException e) {
  +            log("Can't load sessions from store, " + e.getMessage(), e);
  +            return;
  +        }
  +        
           int n = ids.length;
           if (n == 0)
               return;
  @@ -426,7 +433,11 @@
               log(sm.getString("persistentManager.loading", String.valueOf(n)));
   
           for (int i = 0; i < n; i++)
  -            swapIn(ids[i]);
  +            try {
  +                swapIn(ids[i]);
  +            } catch (IOException e) {
  +                log("Failed load session from store, " + e.getMessage(), e);
  +            }
           
       }
   
  @@ -441,6 +452,27 @@
   
   
       /**
  +     * Remove this Session from the active Sessions for this Manager,
  +     * and from the Store.
  +     *
  +     * @param session Session to be removed
  +     */
  +    public void remove(Session session) {
  +
  +        super.remove (session);
  +        
  +        if (store != null)
  +            try {
  +                store.remove(session.getId());
  +            } catch (IOException e) {
  +                log("Exception removing session  " + e.getMessage());
  +                e.printStackTrace();
  +            }
  +          
  +    }
  +
  +
  +    /**
        * Save all currently active sessions in the appropriate persistence
        * mechanism, if any.  If persistence is not supported, this method
        * returns without doing anything.
  @@ -539,7 +571,8 @@
   
           ((StandardSession)session).passivate();
           writeSession(session);
  -        session.expire();
  +        super.remove(session);
  +        session.recycle();
   
       }
   
  @@ -658,14 +691,19 @@
           // Stop the background reaper thread
           threadStop();
   
  -        // Expire all active sessions
  +        // Swap out all active sessions
           Session sessions[] = findSessions();
           for (int i = 0; i < sessions.length; i++) {
               StandardSession session = (StandardSession) sessions[i];
               if (!session.isValid())
                   continue;
  -            session.expire();
  -        }
  +            try {
  +                swapOut(session);
  +            } catch (IOException e) {
  +                ;   // Logged upstream
  +            }
  +
  +       }
   
           // Require a new random number generator if we are restarted
           this.random = null;