kief        01/04/08 01:00:41

  Modified:    catalina/src/share/org/apache/catalina/session
                        StandardSession.java
  Log:
  Refactoring to eliminate dependencies by StandardManager, ManagerBase,
  and StandardSession on one another: each should only depend on methods
  found in the interface definitions for Manager and Session.
  
  StandardSession should now function correctly with any correct
  implementation of the Manager interface. The only dependencies are for
  non-critical functionality relating to logging.
  
  Revision  Changes    Path
  1.16      +48 -50    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java
  
  Index: StandardSession.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- StandardSession.java      2001/03/17 00:28:05     1.15
  +++ StandardSession.java      2001/04/08 08:00:40     1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
 1.15 2001/03/17 00:28:05 craigmcc Exp $
  - * $Revision: 1.15 $
  - * $Date: 2001/03/17 00:28:05 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardSession.java,v
 1.16 2001/04/08 08:00:40 kief Exp $
  + * $Revision: 1.16 $
  + * $Date: 2001/04/08 08:00:40 $
    *
    * ====================================================================
    *
  @@ -111,7 +111,7 @@
    * @author Craig R. McClanahan
    * @author Sean Legassick
    * @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
  - * @version $Revision: 1.15 $ $Date: 2001/03/17 00:28:05 $
  + * @version $Revision: 1.16 $ $Date: 2001/04/08 08:00:40 $
    */
   
   class StandardSession
  @@ -130,8 +130,8 @@
   
        super();
        this.manager = manager;
  -        if (manager instanceof StandardManager)
  -            this.debug = ((StandardManager) manager).getDebug();
  +        if (manager instanceof ManagerBase)
  +            this.debug = ((ManagerBase) manager).getDebug();
   
       }
   
  @@ -313,14 +313,13 @@
        */
       public void setId(String id) {
   
  -     if ((this.id != null) && (manager != null) &&
  -       (manager instanceof ManagerBase))
  -         ((ManagerBase) manager).remove(this);
  +     if ((this.id != null) && (manager != null))
  +         manager.remove(this);
   
        this.id = id;
   
  -     if ((manager != null) && (manager instanceof ManagerBase))
  -         ((ManagerBase) manager).add(this);
  +     if (manager != null)
  +         manager.add(this);
   
        // Notify interested application event listeners
        StandardContext context = (StandardContext) manager.getContainer();
  @@ -431,7 +430,18 @@
       }
   
   
  +    /**
  +     * Set the <code>isNew</code> flag for this session.
  +     *
  +     * @param isNew The new value for the <code>isNew</code> flag
  +     */
  +    public void setNew(boolean isNew) {
  +
  +     this.isNew = isNew;
   
  +    }
  +
  +
       /**
        * Return the authenticated Principal that is associated with this Session.
        * This provides an <code>Authenticator</code> with a means to cache a
  @@ -472,6 +482,27 @@
       }
   
   
  +    /**
  +     * Return the <code>isValid</code> flag for this session.
  +     */
  +    public boolean isValid() {
  +
  +     return (this.isValid);
  +
  +    }
  +
  +
  +    /**
  +     * Set the <code>isValid</code> flag for this session.
  +     *
  +     * @param isValid The new value for the <code>isValid</code> flag
  +     */
  +    public void setValid(boolean isValid) {
  +
  +     this.isValid = isValid;
  +    }
  +
  +
       // ------------------------------------------------- Session Public Methods
   
   
  @@ -502,8 +533,8 @@
           setValid(false);
   
        // Remove this session from our manager's active sessions
  -     if ((manager != null) && (manager instanceof ManagerBase))
  -         ((ManagerBase) manager).remove(this);
  +     if (manager != null)
  +         manager.remove(this);
   
        // Unbind any objects associated with this session
        String keys[] = keys();
  @@ -592,16 +623,6 @@
       
       
       /**
  -     * Return the <code>isValid</code> flag for this session.
  -     */
  -    public boolean isValid() {
  -
  -     return (this.isValid);
  -
  -    }
  -
  -
  -    /**
        * Release all object references, and initialize instance variables, in
        * preparation for reuse of this object.
        */
  @@ -663,29 +684,6 @@
   
   
       /**
  -     * Set the <code>isNew</code> flag for this session.
  -     *
  -     * @param isNew The new value for the <code>isNew</code> flag
  -     */
  -    void setNew(boolean isNew) {
  -
  -     this.isNew = isNew;
  -
  -    }
  -
  -
  -    /**
  -     * Set the <code>isValid</code> flag for this session.
  -     *
  -     * @param isValid The new value for the <code>isValid</code> flag
  -     */
  -    void setValid(boolean isValid) {
  -
  -     this.isValid = isValid;
  -    }
  -
  -
  -    /**
        * Write a serialized version of the contents of this session object to
        * the specified object output stream, without requiring that the
        * StandardSession itself have been serialized.
  @@ -1243,8 +1241,8 @@
        */
       private void log(String message) {
   
  -     if ((manager != null) && (manager instanceof StandardManager)) {
  -         ((StandardManager) manager).log(message);
  +     if ((manager != null) && (manager instanceof ManagerBase)) {
  +         ((ManagerBase) manager).log(message);
        } else {
            System.out.println("StandardSession: " + message);
        }
  @@ -1260,8 +1258,8 @@
        */
       private void log(String message, Throwable throwable) {
   
  -     if ((manager != null) && (manager instanceof StandardManager)) {
  -         ((StandardManager) manager).log(message, throwable);
  +     if ((manager != null) && (manager instanceof ManagerBase)) {
  +         ((ManagerBase) manager).log(message, throwable);
        } else {
            System.out.println("StandardSession: " + message);
            throwable.printStackTrace(System.out);
  
  
  

Reply via email to