Author: fhanik
Date: Wed Mar  8 13:38:16 2006
New Revision: 384337

URL: http://svn.apache.org/viewcvs?rev=384337&view=rev
Log:
Removed duplicate string manager
reformatted to readable code

Modified:
    
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java

Modified: 
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java?rev=384337&r1=384336&r2=384337&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
 Wed Mar  8 13:38:16 2006
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,6 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
-
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionAttributeListener;
@@ -42,20 +41,18 @@
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
-import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Session;
 import org.apache.catalina.SessionEvent;
 import org.apache.catalina.SessionListener;
 import org.apache.catalina.ha.ClusterSession;
-import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.StringManager;
 
 /**
- * 
+ *
  * Similar to the StandardSession, this code is identical, but for update and
  * some small issues, simply copied in the first release. This session will 
keep
  * track of deltas during a request.
@@ -69,7 +66,7 @@
  * <b>IMPLEMENTATION NOTE </b>: If you add fields to this class, you must make
  * sure that you carry them over in the read/writeObject methods so that this
  * class is properly serialized.
- * 
+ *
  * @author Filip Hanik
  * @author Craig R. McClanahan
  * @author Sean Legassick
@@ -77,18 +74,17 @@
  * @version $Revision: 372887 $ $Date: 2006-01-27 09:58:58 -0600 (Fri, 27 Jan 
2006) $
  */
 
-public class DeltaSession implements HttpSession, Session, Serializable,
-        ClusterSession {
+public class DeltaSession
+    implements HttpSession, Session, Serializable,
+    ClusterSession {
 
     public static org.apache.commons.logging.Log log = 
org.apache.commons.logging.LogFactory
-            .getLog(DeltaManager.class);
+        .getLog(DeltaManager.class);
 
     /**
      * The string manager for this package.
      */
-    protected static StringManager smp = StringManager
-            .getManager(Constants.Package);
-
+    protected static StringManager sm = 
StringManager.getManager(Constants.Package);
 
     // ----------------------------------------------------- Instance Variables
 
@@ -128,8 +124,10 @@
     /**
      * The method signature for the <code>fireContainerEvent</code> method.
      */
-    private static final Class containerEventTypes[] = { String.class,
-            Object.class };
+    private static final Class containerEventTypes[] = {
+        String.class,
+        Object.class
+    };
 
     /**
      * The time this session was created, in milliseconds since midnight,
@@ -206,11 +204,6 @@
      */
     private transient Principal principal = null;
 
-    /**
-     * The string manager for this package.
-     */
-    private static StringManager sm = StringManager
-            .getManager(Constants.Package);
 
     /**
      * The HTTP session context associated with this session.
@@ -221,8 +214,7 @@
      * The property change support for this component. NOTE: This value is not
      * included in the serialized version of this object.
      */
-    private transient PropertyChangeSupport support = new 
PropertyChangeSupport(
-            this);
+    private transient PropertyChangeSupport support = new 
PropertyChangeSupport(this);
 
     /**
      * The current accessed time for this session.
@@ -239,7 +231,7 @@
 
     /**
      * The delta request contains all the action info
-     *  
+     *
      */
     private transient DeltaRequest deltaRequest = null;
 
@@ -255,15 +247,14 @@
     protected transient int accessCount = 0;
 
     // ----------------------------------------------------------- Constructors
-    
+
     /**
      * Construct a new Session associated with the specified Manager.
-     * 
+     *
      * @param manager
      *            The manager with which this Session is associated
      */
     public DeltaSession(Manager manager) {
-
         super();
         this.manager = manager;
         this.resetDeltaRequest();
@@ -281,7 +272,7 @@
 
     /**
      * Sets whether this is the primary session or not.
-     * 
+     *
      * @param primarySession
      *            Flag value
      */
@@ -302,7 +293,7 @@
     /**
      * Set the authentication type used to authenticate our cached Principal, 
if
      * any.
-     * 
+     *
      * @param authType
      *            The new cached authentication type
      */
@@ -317,7 +308,7 @@
     /**
      * Set the creation time for this session. This method is called by the
      * Manager when an existing Session instance is reused.
-     * 
+     *
      * @param time
      *            The new creation time
      */
@@ -337,7 +328,6 @@
 
     }
 
-
     /**
      * Return the session identifier for this session.
      */
@@ -347,39 +337,34 @@
 
     }
 
-
     /**
      * Set the session identifier for this session without notify listeners.
-     * 
+     *
      * @param id
      *            The new session identifier
      */
     public void setIdInternal(String id) {
-        if ((this.id != null) && (manager != null))
-            manager.remove(this);
-
+        if ( (this.id != null) && (manager != null)) manager.remove(this);
         this.id = id;
-
-        if (manager != null)
-            manager.add(this);
-        if ( deltaRequest == null ) resetDeltaRequest();
+        if (manager != null) manager.add(this);
+        if (deltaRequest == null) resetDeltaRequest();
         else deltaRequest.setSessionId(id);
     }
 
     /**
      * Set the session identifier for this session.
-     * 
+     *
      * @param id
      *            The new session identifier
      */
     public void setId(String id) {
         setIdInternal(id);
         tellNew();
-     }
+    }
 
     /**
      * Inform the listeners about the new session.
-     *  
+     *
      */
     public void tellNew() {
 
@@ -394,25 +379,19 @@
             if (listeners != null) {
                 HttpSessionEvent event = new HttpSessionEvent(getSession());
                 for (int i = 0; i < listeners.length; i++) {
-                    if (!(listeners[i] instanceof HttpSessionListener))
+                    if (! (listeners[i] instanceof HttpSessionListener))
                         continue;
                     HttpSessionListener listener = (HttpSessionListener) 
listeners[i];
                     try {
-                        fireContainerEvent(context, "beforeSessionCreated",
-                                listener);
+                        fireContainerEvent(context, 
"beforeSessionCreated",listener);
                         listener.sessionCreated(event);
-                        fireContainerEvent(context, "afterSessionCreated",
-                                listener);
+                        fireContainerEvent(context, 
"afterSessionCreated",listener);
                     } catch (Throwable t) {
                         try {
-                            fireContainerEvent(context, "afterSessionCreated",
-                                    listener);
-                        } catch (Exception e) {
-                            ;
-                        }
+                            fireContainerEvent(context, 
"afterSessionCreated",listener);
+                        } catch (Exception e) {}
                         // FIXME - should we do anything besides log these?
-                        log.error(sm.getString("standardSession.sessionEvent"),
-                                t);
+                        
log.error(sm.getString("standardSession.sessionEvent"),t);
                     }
                 }
             }
@@ -437,12 +416,11 @@
      * value associated with the session, do not affect the access time.
      */
     public long getLastAccessedTime() {
-       
-                if (!isValid()) {
-            throw new IllegalStateException(sm
-                    .getString("standardSession.getId.ise"));
+
+        if (!isValid()) {
+            throw new 
IllegalStateException(sm.getString("standardSession.getId.ise"));
         }
-               return (this.lastAccessedTime);
+        return (this.lastAccessedTime);
 
     }
 
@@ -450,21 +428,17 @@
      * Return the Manager within which this Session is valid.
      */
     public Manager getManager() {
-
         return (this.manager);
-
     }
 
     /**
      * Set the Manager within which this Session is valid.
-     * 
+     *
      * @param manager
      *            The new Manager
      */
     public void setManager(Manager manager) {
-
         this.manager = manager;
-
     }
 
     /**
@@ -473,16 +447,14 @@
      * indicates that the session should never time out.
      */
     public int getMaxInactiveInterval() {
-
         return (this.maxInactiveInterval);
-
     }
 
     /**
      * Set the maximum time interval, in seconds, between client requests 
before
      * the servlet container will invalidate the session. A negative time
      * indicates that the session should never time out.
-     * 
+     *
      * @param interval
      *            The new maximum interval
      */
@@ -491,7 +463,6 @@
     }
 
     public void setMaxInactiveInterval(int interval, boolean addDeltaRequest) {
-
         this.maxInactiveInterval = interval;
         if (isValid && interval == 0) {
             expire();
@@ -499,12 +470,11 @@
             if (addDeltaRequest && (deltaRequest != null))
                 deltaRequest.setMaxInactiveInterval(interval);
         }
-
     }
 
     /**
      * Set the <code>isNew</code> flag for this session.
-     * 
+     *
      * @param isNew
      *            The new value for the <code>isNew</code> flag
      */
@@ -526,9 +496,7 @@
      * no current associated Principal, return <code>null</code>.
      */
     public Principal getPrincipal() {
-
         return (this.principal);
-
     }
 
     /**
@@ -536,7 +504,7 @@
      * This provides an <code>Authenticator</code> with a means to cache a
      * previously authenticated Principal, and avoid potentially expensive
      * <code>Realm.authenticate()</code> calls on every request.
-     * 
+     *
      * @param principal
      *            The new Principal, or <code>null</code> if none
      */
@@ -557,70 +525,62 @@
      * facade.
      */
     public HttpSession getSession() {
-
         if (facade == null) {
             if (System.getSecurityManager() != null) {
                 final DeltaSession fsession = this;
                 facade = (DeltaSessionFacade) AccessController
-                        .doPrivileged(new PrivilegedAction() {
-                            public Object run() {
-                                return new DeltaSessionFacade(fsession);
-                            }
-                        });
+                         .doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        return new DeltaSessionFacade(fsession);
+                    }
+                });
             } else {
                 facade = new DeltaSessionFacade(this);
             }
         }
         return (facade);
-
     }
 
     /**
      * Return the <code>isValid</code> flag for this session.
      */
     public boolean isValid() {
-
         if (this.expiring) {
             return true;
         }
-
         if (!this.isValid) {
             return false;
         }
-
         if (accessCount > 0) {
             return true;
         }
-
         if (maxInactiveInterval >= 0) {
             long timeNow = System.currentTimeMillis();
-            int timeIdle = (int) ((timeNow - lastAccessedTime) / 1000L);
+            int timeIdle = (int) ( (timeNow - lastAccessedTime) / 1000L);
             if (isPrimarySession()) {
-                if(timeIdle >= maxInactiveInterval) {
+                if (timeIdle >= maxInactiveInterval) {
                     expire(true);
                 }
             } else {
                 if (timeIdle >= (2 * maxInactiveInterval)) {
-                //if the session has been idle twice as long as allowed,
-                //the primary session has probably crashed, and no other
-                //requests are coming in. that is why we do this. otherwise
-                //we would have a memory leak
+                    //if the session has been idle twice as long as allowed,
+                    //the primary session has probably crashed, and no other
+                    //requests are coming in. that is why we do this. otherwise
+                    //we would have a memory leak
                     expire(true, false);
                 }
             }
         }
-
         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;
     }
 
@@ -632,31 +592,26 @@
      * session, even if the application does not reference it.
      */
     public void access() {
-
         this.lastAccessedTime = this.thisAccessedTime;
         this.thisAccessedTime = System.currentTimeMillis();
-
         evaluateIfValid();
-
         accessCount++;
     }
 
     public void endAccess() {
         isNew = false;
         accessCount--;
-        if(manager instanceof DeltaManager)
-            ((DeltaManager)manager).registerSessionAtReplicationValve(this);
+        if (manager instanceof DeltaManager)
+            ( (DeltaManager) manager).registerSessionAtReplicationValve(this);
     }
 
     /**
      * Add a session event listener to this component.
      */
     public void addSessionListener(SessionListener listener) {
-
         synchronized (listeners) {
             listeners.add(listener);
         }
-
     }
 
     /**
@@ -664,15 +619,13 @@
      * without triggering an exception if the session has already expired.
      */
     public void expire() {
-
         expire(true);
-
     }
 
     /**
      * Perform the internal processing required to invalidate this session,
      * without triggering an exception if the session has already expired.
-     * 
+     *
      * @param notify
      *            Should we notify listeners about the demise of this session?
      */
@@ -681,7 +634,6 @@
     }
 
     public void expire(boolean notify, boolean notifyCluster) {
-
         // Mark this session as "being expired" if needed
         if (expiring)
             return;
@@ -704,30 +656,25 @@
                     HttpSessionEvent event = new 
HttpSessionEvent(getSession());
                     for (int i = 0; i < listeners.length; i++) {
                         int j = (listeners.length - 1) - i;
-                        if (!(listeners[j] instanceof HttpSessionListener))
+                        if (! (listeners[j] instanceof HttpSessionListener))
                             continue;
                         HttpSessionListener listener = (HttpSessionListener) 
listeners[j];
                         try {
-                            fireContainerEvent(context,
-                                    "beforeSessionDestroyed", listener);
+                            
fireContainerEvent(context,"beforeSessionDestroyed", listener);
                             listener.sessionDestroyed(event);
-                            fireContainerEvent(context,
-                                    "afterSessionDestroyed", listener);
+                            
fireContainerEvent(context,"afterSessionDestroyed", listener);
                         } catch (Throwable t) {
                             try {
-                                fireContainerEvent(context,
-                                        "afterSessionDestroyed", listener);
+                                
fireContainerEvent(context,"afterSessionDestroyed", listener);
                             } catch (Exception e) {
                                 ;
                             }
                             // FIXME - should we do anything besides log these?
-                            log.error(sm
-                                    .getString("standardSession.sessionEvent"),
-                                    t);
+                            
log.error(sm.getString("standardSession.sessionEvent"),t);
                         }
                     }
                 }
-            }//end if
+            } //end if
             //end fix
             accessCount = 0;
             setValid(false);
@@ -751,12 +698,12 @@
 
             if (notifyCluster) {
                 if (log.isDebugEnabled())
-                    log.debug(smp.getString("deltaSession.notifying",
-                            ((DeltaManager) manager).getName(), new Boolean(
-                                    isPrimarySession()), expiredId));
-                ((DeltaManager) manager).sessionExpired(expiredId);
+                    log.debug(sm.getString("deltaSession.notifying",
+                                           ((DeltaManager)manager).getName(), 
+                                           new Boolean(isPrimarySession()), 
+                                           expiredId));
+                ( (DeltaManager) manager).sessionExpired(expiredId);
             }
-
         }
 
     }
@@ -764,12 +711,12 @@
     /**
      * Return the object bound with the specified name to the internal notes 
for
      * this session, or <code>null</code> if no such binding exists.
-     * 
+     *
      * @param name
      *            Name of the note to be returned
      */
     public Object getNote(String name) {
-            return (notes.get(name));
+        return (notes.get(name));
     }
 
     /**
@@ -777,7 +724,7 @@
      * exist for this session.
      */
     public Iterator getNoteNames() {
-            return (notes.keySet().iterator());
+        return (notes.keySet().iterator());
     }
 
     /**
@@ -785,7 +732,6 @@
      * preparation for reuse of this object.
      */
     public void recycle() {
-
         // Reset the instance variables associated with this Session
         attributes.clear();
         setAuthType(null);
@@ -801,13 +747,12 @@
         isValid = false;
         manager = null;
         deltaRequest.clear();
-
     }
 
     /**
      * Remove any object bound to the specified name in the internal notes for
      * this session.
-     * 
+     *
      * @param name
      *            Name of the note to be removed
      */
@@ -819,17 +764,15 @@
      * Remove a session event listener from this component.
      */
     public void removeSessionListener(SessionListener listener) {
-
         synchronized (listeners) {
             listeners.remove(listener);
         }
-
     }
 
     /**
      * Bind an object to a specified name in the internal notes associated with
      * this session, replacing any existing binding for this name.
-     * 
+     *
      * @param name
      *            Name to which the object should be bound
      * @param value
@@ -843,13 +786,11 @@
      * Return a string representation of this object.
      */
     public String toString() {
-
         StringBuffer sb = new StringBuffer();
         sb.append("DeltaSession[");
         sb.append(id);
         sb.append("]");
         return (sb.toString());
-
     }
 
     // ------------------------------------------------ Session Package Methods
@@ -858,37 +799,32 @@
      * Read a serialized version of the contents of this session object from 
the
      * specified object input stream, without requiring that the 
StandardSession
      * itself have been serialized.
-     * 
+     *
      * @param stream
      *            The object input stream to read from
-     * 
+     *
      * @exception ClassNotFoundException
      *                if an unknown class is specified
      * @exception IOException
      *                if an input/output error occurs
      */
-    public void readObjectData(ObjectInputStream stream)
-            throws ClassNotFoundException, IOException {
-
+    public void readObjectData(ObjectInputStream stream) throws 
ClassNotFoundException, IOException {
         readObject(stream);
-
     }
 
     /**
      * 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.
-     * 
+     *
      * @param stream
      *            The object output stream to write to
-     * 
+     *
      * @exception IOException
      *                if an input/output error occurs
      */
     public void writeObjectData(ObjectOutputStream stream) throws IOException {
-
         writeObject(stream);
-
     }
 
     public void resetDeltaRequest() {
@@ -901,8 +837,7 @@
     }
 
     public DeltaRequest getDeltaRequest() {
-        if (deltaRequest == null)
-            resetDeltaRequest();
+        if (deltaRequest == null) resetDeltaRequest();
         return deltaRequest;
     }
 
@@ -911,25 +846,20 @@
     /**
      * Return the time when this session was created, in milliseconds since
      * midnight, January 1, 1970 GMT.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public long getCreationTime() {
-
         if (!expiring && !isValid)
-            throw new IllegalStateException(sm
-                    .getString("standardSession.getCreationTime.ise"));
-
+            throw new 
IllegalStateException(sm.getString("standardSession.getCreationTime.ise"));
         return (this.creationTime);
-
     }
 
     /**
      * Return the ServletContext to which this session belongs.
      */
     public ServletContext getServletContext() {
-
         if (manager == null)
             return (null);
         Context context = (Context) manager.getContainer();
@@ -937,22 +867,19 @@
             return (null);
         else
             return (context.getServletContext());
-
     }
 
     /**
      * Return the session context with which this session is associated.
-     * 
+     *
      * @deprecated As of Version 2.1, this method is deprecated and has no
      *             replacement. It will be removed in a future version of the
      *             Java Servlet API.
      */
     public HttpSessionContext getSessionContext() {
-
         if (sessionContext == null)
             sessionContext = new StandardSessionContext();
         return (sessionContext);
-
     }
 
     // ----------------------------------------------HttpSession Public Methods
@@ -960,90 +887,76 @@
     /**
      * Return the object bound with the specified name in this session, or
      * <code>null</code> if no object is bound with that name.
-     * 
+     *
      * @param name
      *            Name of the attribute to be returned
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public Object getAttribute(String name) {
-
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.getAttribute.ise"));
+            throw new 
IllegalStateException(sm.getString("standardSession.getAttribute.ise"));
         return (attributes.get(name));
     }
 
     /**
      * Return an <code>Enumeration</code> of <code>String</code> objects
      * containing the names of the objects bound to this session.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public Enumeration getAttributeNames() {
-
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.getAttributeNames.ise"));
+            throw new 
IllegalStateException(sm.getString("standardSession.getAttributeNames.ise"));
         return (new Enumerator(attributes.keySet(), true));
     }
 
     /**
      * Return the object bound with the specified name in this session, or
      * <code>null</code> if no object is bound with that name.
-     * 
+     *
      * @param name
      *            Name of the value to be returned
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
-     * 
+     *
      * @deprecated As of Version 2.2, this method is replaced by
      *             <code>getAttribute()</code>
      */
     public Object getValue(String name) {
-
         return (getAttribute(name));
-
     }
 
     /**
      * Return the set of names of objects bound to this session. If there are 
no
      * such objects, a zero-length array is returned.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
-     * 
+     *
      * @deprecated As of Version 2.2, this method is replaced by
      *             <code>getAttributeNames()</code>
      */
     public String[] getValueNames() {
-
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.getValueNames.ise"));
-
+            throw new 
IllegalStateException(sm.getString("standardSession.getValueNames.ise"));
         return (keys());
-
     }
 
     /**
      * Invalidates this session and unbinds any objects bound to it.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public void invalidate() {
-
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.invalidate.ise"));
-
+            throw new 
IllegalStateException(sm.getString("standardSession.invalidate.ise"));
         // Cause this session to expire
         expire();
-
     }
 
     /**
@@ -1051,18 +964,14 @@
      * session, or if the client chooses not to join the session. For example,
      * if the server used only cookie-based sessions, and the client has
      * disabled the use of cookies, then a session would be new on each 
request.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public boolean isNew() {
-
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.isNew.ise"));
-
+            throw new 
IllegalStateException(sm.getString("standardSession.isNew.ise"));
         return (this.isNew);
-
     }
 
     /**
@@ -1072,22 +981,20 @@
      * After this method executes, and if the object implements
      * <code>HttpSessionBindingListener</code>, the container calls
      * <code>valueBound()</code> on the object.
-     * 
+     *
      * @param name
      *            Name to which the object is bound, cannot be null
      * @param value
      *            Object to be bound, cannot be null
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
-     * 
+     *
      * @deprecated As of Version 2.2, this method is replaced by
      *             <code>setAttribute()</code>
      */
     public void putValue(String name, Object value) {
-
         setAttribute(name, value);
-
     }
 
     /**
@@ -1098,17 +1005,15 @@
      * After this method executes, and if the object implements
      * <code>HttpSessionBindingListener</code>, the container calls
      * <code>valueUnbound()</code> on the object.
-     * 
+     *
      * @param name
      *            Name of the object to remove from this session.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
     public void removeAttribute(String name) {
-
         removeAttribute(name, true);
-
     }
 
     /**
@@ -1119,13 +1024,13 @@
      * After this method executes, and if the object implements
      * <code>HttpSessionBindingListener</code>, the container calls
      * <code>valueUnbound()</code> on the object.
-     * 
+     *
      * @param name
      *            Name of the object to remove from this session.
      * @param notify
      *            Should we notify interested listeners that this attribute is
      *            being removed?
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
      */
@@ -1134,12 +1039,10 @@
     }
 
     public void removeAttribute(String name, boolean notify,
-            boolean addDeltaRequest) {
-
+                                boolean addDeltaRequest) {
         // Validate our current state
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.removeAttribute.ise"));
+            throw new 
IllegalStateException(sm.getString("standardSession.removeAttribute.ise"));
         removeAttributeInternal(name, notify, addDeltaRequest);
     }
 
@@ -1151,20 +1054,18 @@
      * After this method executes, and if the object implements
      * <code>HttpSessionBindingListener</code>, the container calls
      * <code>valueUnbound()</code> on the object.
-     * 
+     *
      * @param name
      *            Name of the object to remove from this session.
-     * 
+     *
      * @exception IllegalStateException
      *                if this method is called on an invalidated session
-     * 
+     *
      * @deprecated As of Version 2.2, this method is replaced by
      *             <code>removeAttribute()</code>
      */
     public void removeValue(String name) {
-
         removeAttribute(name);
-
     }
 
     /**
@@ -1174,12 +1075,12 @@
      * After this method executes, and if the object implements
      * <code>HttpSessionBindingListener</code>, the container calls
      * <code>valueBound()</code> on the object.
-     * 
+     *
      * @param name
      *            Name to which the object is bound, cannot be null
      * @param value
      *            Object to be bound, cannot be null
-     * 
+     *
      * @exception IllegalArgumentException
      *                if an attempt is made to add a non-serializable object in
      *                an environment marked distributable.
@@ -1191,12 +1092,11 @@
     }
 
     public void setAttribute(String name, Object value, boolean notify,
-            boolean addDeltaRequest) {
+                             boolean addDeltaRequest) {
 
         // Name cannot be null
         if (name == null)
-            throw new IllegalArgumentException(sm
-                    .getString("standardSession.setAttribute.namenull"));
+            throw new 
IllegalArgumentException(sm.getString("standardSession.setAttribute.namenull"));
 
         // Null value is the same as removeAttribute()
         if (value == null) {
@@ -1206,17 +1106,14 @@
 
         // Validate our current state
         if (!isValid())
-            throw new IllegalStateException(sm
-                    .getString("standardSession.setAttribute.ise"));
-        if (!(value instanceof java.io.Serializable)) {
-            throw new IllegalArgumentException("Attribute [" + name
-                    + "] is not serializable");
+            throw new 
IllegalStateException(sm.getString("standardSession.setAttribute.ise"));
+        if (! (value instanceof java.io.Serializable)) {
+            throw new IllegalArgumentException("Attribute [" + name + "] is 
not serializable");
         }
 
         if (addDeltaRequest && (deltaRequest != null))
             deltaRequest.setAttribute(name, value);
 
-
         // Construct an event with the new value
         HttpSessionBindingEvent event = null;
 
@@ -1227,9 +1124,9 @@
             if (value != oldValue) {
                 event = new HttpSessionBindingEvent(getSession(), name, value);
                 try {
-                    ((HttpSessionBindingListener) value).valueBound(event);
+                    ( (HttpSessionBindingListener) value).valueBound(event);
                 } catch (Exception x) {
-                    log.error(smp.getString("deltaSession.valueBound.ex"), x);
+                    log.error(sm.getString("deltaSession.valueBound.ex"), x);
                 }
             }
         }
@@ -1237,14 +1134,12 @@
         // Replace or add this attribute
         Object unbound = attributes.put(name, value);
         // Call the valueUnbound() method if necessary
-        if ((unbound != null) && (unbound != value) && notify
-                && (unbound instanceof HttpSessionBindingListener)) {
+        if ( (unbound != null) && (unbound != value) && notify
+            && (unbound instanceof HttpSessionBindingListener)) {
             try {
-                ((HttpSessionBindingListener) unbound)
-                        .valueUnbound(new HttpSessionBindingEvent(
-                                (HttpSession) getSession(), name));
+                ( (HttpSessionBindingListener) unbound).valueUnbound(new 
HttpSessionBindingEvent((HttpSession) getSession(), name));
             } catch (Exception x) {
-                log.error(smp.getString("deltaSession.valueBinding.ex"), x);
+                log.error(sm.getString("deltaSession.valueBinding.ex"), x);
             }
 
         }
@@ -1261,52 +1156,39 @@
             if (listeners == null)
                 return;
             for (int i = 0; i < listeners.length; i++) {
-                if (!(listeners[i] instanceof HttpSessionAttributeListener))
+                if (! (listeners[i] instanceof HttpSessionAttributeListener))
                     continue;
                 HttpSessionAttributeListener listener = 
(HttpSessionAttributeListener) listeners[i];
                 try {
                     if (unbound != null) {
-                        fireContainerEvent(context,
-                                "beforeSessionAttributeReplaced", listener);
+                        
fireContainerEvent(context,"beforeSessionAttributeReplaced", listener);
                         if (event == null) {
-                            event = new HttpSessionBindingEvent(getSession(),
-                                    name, unbound);
+                            event = new 
HttpSessionBindingEvent(getSession(),name, unbound);
                         }
                         listener.attributeReplaced(event);
-                        fireContainerEvent(context,
-                                "afterSessionAttributeReplaced", listener);
+                        
fireContainerEvent(context,"afterSessionAttributeReplaced", listener);
                     } else {
-                        fireContainerEvent(context,
-                                "beforeSessionAttributeAdded", listener);
+                        
fireContainerEvent(context,"beforeSessionAttributeAdded", listener);
                         if (event == null) {
-                            event = new HttpSessionBindingEvent(getSession(),
-                                    name, value);
+                            event = 
+                                new HttpSessionBindingEvent(getSession(),name, 
value);
                         }
                         listener.attributeAdded(event);
-                        fireContainerEvent(context,
-                                "afterSessionAttributeAdded", listener);
+                        
fireContainerEvent(context,"afterSessionAttributeAdded", listener);
                     }
                 } catch (Throwable t) {
                     try {
                         if (unbound != null) {
-                            fireContainerEvent(context,
-                                    "afterSessionAttributeReplaced", listener);
+                            
fireContainerEvent(context,"afterSessionAttributeReplaced", listener);
                         } else {
-                            fireContainerEvent(context,
-                                    "afterSessionAttributeAdded", listener);
+                            
fireContainerEvent(context,"afterSessionAttributeAdded", listener);
                         }
-                    } catch (Exception e) {
-                        ;
-                    }
+                    } catch (Exception e) {}
                     // FIXME - should we do anything besides log these?
-                    log
-                            .error(
-                                    sm
-                                            
.getString("standardSession.attributeEvent"),
-                                    t);
+                    
log.error(sm.getString("standardSession.attributeEvent"),t);
                 }
             } //for
-        }//end if
+        } //end if
         //end fix
 
     }
@@ -1319,57 +1201,53 @@
      * <p>
      * <b>IMPLEMENTATION NOTE </b>: The reference to the owning Manager is not
      * restored by this method, and must be set explicitly.
-     * 
+     *
      * @param stream
      *            The input stream to read from
-     * 
+     *
      * @exception ClassNotFoundException
      *                if an unknown class is specified
      * @exception IOException
      *                if an input/output error occurs
      */
-    private void readObject(ObjectInputStream stream)
-            throws ClassNotFoundException, IOException {
+    private void readObject(ObjectInputStream stream) throws 
ClassNotFoundException, IOException {
 
         // Deserialize the scalar instance variables (except Manager)
         authType = null; // Transient only
-        creationTime = ((Long) stream.readObject()).longValue();
-        lastAccessedTime = ((Long) stream.readObject()).longValue();
-        maxInactiveInterval = ((Integer) stream.readObject()).intValue();
-        isNew = ((Boolean) stream.readObject()).booleanValue();
-        isValid = ((Boolean) stream.readObject()).booleanValue();
-        thisAccessedTime = ((Long) stream.readObject()).longValue();
+        creationTime = ( (Long) stream.readObject()).longValue();
+        lastAccessedTime = ( (Long) stream.readObject()).longValue();
+        maxInactiveInterval = ( (Integer) stream.readObject()).intValue();
+        isNew = ( (Boolean) stream.readObject()).booleanValue();
+        isValid = ( (Boolean) stream.readObject()).booleanValue();
+        thisAccessedTime = ( (Long) stream.readObject()).longValue();
         boolean hasPrincipal = stream.readBoolean();
         principal = null;
         if (hasPrincipal) {
-            principal = SerializablePrincipal.readPrincipal(stream,
-                    getManager().getContainer().getRealm());
+            principal = 
SerializablePrincipal.readPrincipal(stream,getManager().getContainer().getRealm());
         }
 
         //        setId((String) stream.readObject());
         id = (String) stream.readObject();
-        if (log.isDebugEnabled())
-            log.debug(smp.getString("deltaSession.readSession",  id));
+        if (log.isDebugEnabled()) 
log.debug(sm.getString("deltaSession.readSession", id));
 
         // Deserialize the attribute count and attribute values
-        if (attributes == null)
-            attributes = new Hashtable();
-        int n = ((Integer) stream.readObject()).intValue();
+        if (attributes == null) attributes = new Hashtable();
+        int n = ( (Integer) stream.readObject()).intValue();
         boolean isValidSave = isValid;
         isValid = true;
         for (int i = 0; i < n; i++) {
             String name = (String) stream.readObject();
             Object value = (Object) stream.readObject();
-            if ((value instanceof String) && (value.equals(NOT_SERIALIZED)))
+            if ( (value instanceof String) && (value.equals(NOT_SERIALIZED)))
                 continue;
             attributes.put(name, value);
         }
         isValid = isValidSave;
-        
+
         if (listeners == null) {
             listeners = new ArrayList();
         }
-        
+
         if (notes == null) {
             notes = new Hashtable();
         }
@@ -1389,10 +1267,10 @@
      * HttpSessionBindingListener. If you do not want any such attributes, be
      * sure the <code>distributable</code> property of the associated Manager
      * is set to <code>true</code>.
-     * 
+     *
      * @param stream
      *            The output stream to write to
-     * 
+     *
      * @exception IOException
      *                if an input/output error occurs
      */
@@ -1407,13 +1285,11 @@
         stream.writeObject(new Long(thisAccessedTime));
         stream.writeBoolean(getPrincipal() != null);
         if (getPrincipal() != null) {
-            SerializablePrincipal.writePrincipal((GenericPrincipal) principal,
-                    stream);
+            SerializablePrincipal.writePrincipal((GenericPrincipal) 
principal,stream);
         }
 
         stream.writeObject(id);
-        if (log.isDebugEnabled())
-            log.debug(smp.getString("deltaSession.writeSession",id));
+        if (log.isDebugEnabled()) 
log.debug(sm.getString("deltaSession.writeSession", id));
 
         // Accumulate the names of serializable and non-serializable attributes
         String keys[] = keys();
@@ -1434,18 +1310,13 @@
         int n = saveNames.size();
         stream.writeObject(new Integer(n));
         for (int i = 0; i < n; i++) {
-            stream.writeObject((String) saveNames.get(i));
+            stream.writeObject( (String) saveNames.get(i));
             try {
                 stream.writeObject(saveValues.get(i));
-                //                if (log.isDebugEnabled())
-                //                    log.debug(" storing attribute '" + 
saveNames.get(i) +
-                //                        "' with value '" + saveValues.get(i) 
+ "'");
             } catch (NotSerializableException e) {
-                log.error(sm.getString("standardSession.notSerializable",
-                        saveNames.get(i), id), e);
+                
log.error(sm.getString("standardSession.notSerializable",saveNames.get(i), id), 
e);
                 stream.writeObject(NOT_SERIALIZED);
-                log.error("  storing attribute '" + saveNames.get(i)
-                        + "' with value NOT_SERIALIZED");
+                log.error("  storing attribute '" + saveNames.get(i)+ "' with 
value NOT_SERIALIZED");
             }
         }
 
@@ -1458,9 +1329,7 @@
          */
         if (!this.isValid || expiring || maxInactiveInterval < 0)
             return;
-
         isValid();
-
     }
 
     // -------------------------------------------------------- Private Methods
@@ -1468,41 +1337,36 @@
     /**
      * Fire container events if the Context implementation is the
      * <code>org.apache.catalina.core.StandardContext</code>.
-     * 
+     *
      * @param context
      *            Context for which to fire events
      * @param type
      *            Event type
      * @param data
      *            Event data
-     * 
+     *
      * @exception Exception
      *                occurred during event firing
      */
-    private void fireContainerEvent(Context context, String type, Object data)
-            throws Exception {
-
-        if (!"org.apache.catalina.core.StandardContext".equals(context
-                .getClass().getName())) {
+    private void fireContainerEvent(Context context, String type, Object data) 
throws Exception {
+        if 
(!"org.apache.catalina.core.StandardContext".equals(context.getClass().getName()))
 {
             return; // Container events are not supported
         }
         // NOTE: Race condition is harmless, so do not synchronize
         if (containerEventMethod == null) {
-            containerEventMethod = context.getClass().getMethod(
-                    "fireContainerEvent", containerEventTypes);
+            containerEventMethod = 
context.getClass().getMethod("fireContainerEvent", containerEventTypes);
         }
         Object containerEventParams[] = new Object[2];
         containerEventParams[0] = type;
         containerEventParams[1] = data;
         containerEventMethod.invoke(context, containerEventParams);
-
     }
 
     /**
      * Notify all session event listeners that a particular event has occurred
      * for this Session. The default implementation performs this notification
      * synchronously using the calling thread.
-     * 
+     *
      * @param type
      *            Event type
      * @param data
@@ -1518,9 +1382,8 @@
         }
 
         for (int i = 0; i < list.length; i++) {
-            ((SessionListener) list[i]).sessionEvent(event);
+            ( (SessionListener) list[i]).sessionEvent(event);
         }
-
     }
 
     /**
@@ -1529,18 +1392,18 @@
      * returned.
      */
     protected String[] keys() {
-        return ((String[]) attributes.keySet().toArray(EMPTY_ARRAY));
+        return ( (String[]) attributes.keySet().toArray(EMPTY_ARRAY));
     }
 
     /**
      * Return the value of an attribute without a check for validity.
      */
     protected Object getAttributeInternal(String name) {
-        return (attributes.get(name));  
+        return (attributes.get(name));
     }
 
     protected void removeAttributeInternal(String name, boolean notify,
-            boolean addDeltaRequest) {
+                                           boolean addDeltaRequest) {
 
         // Remove this attribute from our collection
         Object value = attributes.remove(name);
@@ -1556,14 +1419,13 @@
         }
 
         // Call the valueUnbound() method if necessary
-         HttpSessionBindingEvent event = null;
-         if (value instanceof HttpSessionBindingListener) {
-            event = new HttpSessionBindingEvent(
-                (HttpSession) getSession(), name, value);
+        HttpSessionBindingEvent event = null;
+        if (value instanceof HttpSessionBindingListener) {
+            event = new HttpSessionBindingEvent((HttpSession) getSession(), 
name, value);
             try {
-                ((HttpSessionBindingListener) value).valueUnbound(event);
+                ( (HttpSessionBindingListener) value).valueUnbound(event);
             } catch (Exception x) {
-                log.error(smp.getString("deltaSession.valueUnbound.ex"), x);
+                log.error(sm.getString("deltaSession.valueUnbound.ex"), x);
             }
         }
         // Notify interested application event listeners
@@ -1574,35 +1436,27 @@
             if (listeners == null)
                 return;
             for (int i = 0; i < listeners.length; i++) {
-                if (!(listeners[i] instanceof HttpSessionAttributeListener))
+                if (! (listeners[i] instanceof HttpSessionAttributeListener))
                     continue;
                 HttpSessionAttributeListener listener = 
(HttpSessionAttributeListener) listeners[i];
                 try {
-                    fireContainerEvent(context,
-                            "beforeSessionAttributeRemoved", listener);
+                    
fireContainerEvent(context,"beforeSessionAttributeRemoved", listener);
                     if (event == null) {
-                        event = new HttpSessionBindingEvent
-                            (getSession(), name, value);
+                        event = new HttpSessionBindingEvent(getSession(), 
name, value);
                     }
                     listener.attributeRemoved(event);
-                    fireContainerEvent(context, "afterSessionAttributeRemoved",
-                            listener);
+                    fireContainerEvent(context, 
"afterSessionAttributeRemoved",listener);
                 } catch (Throwable t) {
                     try {
-                        fireContainerEvent(context,
-                                "afterSessionAttributeRemoved", listener);
+                        
fireContainerEvent(context,"afterSessionAttributeRemoved", listener);
                     } catch (Exception e) {
                         ;
                     }
                     // FIXME - should we do anything besides log these?
-                    log
-                            .error(
-                                    sm
-                                            
.getString("standardSession.attributeEvent"),
-                                    t);
+                    
log.error(sm.getString("standardSession.attributeEvent"),t);
                 }
             } //for
-        }//end if
+        } //end if
         //end fix
 
     }
@@ -1631,46 +1485,43 @@
  * This class is a dummy implementation of the <code>HttpSessionContext</code>
  * interface, to conform to the requirement that such an object be returned 
when
  * <code>HttpSession.getSessionContext()</code> is called.
- * 
+ *
  * @author Craig R. McClanahan
- * 
+ *
  * @deprecated As of Java Servlet API 2.1 with no replacement. The interface
  *             will be removed in a future version of this API.
  */
 
-final class StandardSessionContext implements HttpSessionContext {
+final class StandardSessionContext
+    implements HttpSessionContext {
 
     private HashMap dummy = new HashMap();
 
     /**
      * Return the session identifiers of all sessions defined within this
      * context.
-     * 
+     *
      * @deprecated As of Java Servlet API 2.1 with no replacement. This method
      *             must return an empty <code>Enumeration</code> and will be
      *             removed in a future version of the API.
      */
     public Enumeration getIds() {
-
         return (new Enumerator(dummy));
-
     }
 
     /**
      * Return the <code>HttpSession</code> associated with the specified
      * session identifier.
-     * 
+     *
      * @param id
      *            Session identifier for which to look up a session
-     * 
+     *
      * @deprecated As of Java Servlet API 2.1 with no replacement. This method
      *             must return null and will be removed in a future version of
      *             the API.
      */
     public HttpSession getSession(String id) {
-
         return (null);
-
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to