| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.session.StandardSession
public class StandardSession
Standard implementation of the Session interface. This object is serializable, so that it can be stored in persistent storage or transferred to a different JVM for distributable session support.
 IMPLEMENTATION NOTE:  An instance of this class represents both the
 internal (Session) and application level (HttpSession) view of the session.
 However, because the class itself is not declared public, Java logic outside
 of the org.apache.catalina.session package cannot cast an
 HttpSession view of this instance back to a Session view.
 
IMPLEMENTATION NOTE: 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.
| Field Summary | |
|---|---|
| protected  java.util.concurrent.atomic.AtomicInteger | accessCountThe access count for this session. | 
| protected static boolean | ACTIVITY_CHECK | 
| protected  java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> | attributesThe collection of user data attributes associated with this Session. | 
| protected  java.lang.String | authTypeThe authentication type used to authenticate our cached Principal, if any. | 
| protected  long | creationTimeThe time this session was created, in milliseconds since midnight, January 1, 1970 GMT. | 
| protected static java.lang.String[] | EMPTY_ARRAYType array. | 
| protected static java.lang.String[] | excludedAttributesDeprecated. Use Constants.excludedAttributeNamesinstead. Will be
             removed in Tomcat 9. | 
| protected  boolean | expiringWe are currently processing a session expiration, so bypass certain IllegalStateException tests. | 
| protected  StandardSessionFacade | facadeThe facade associated with this session. | 
| protected  java.lang.String | idThe session identifier of this Session. | 
| protected static java.lang.String | infoDescriptive information describing this Session implementation. | 
| protected  boolean | isNewFlag indicating whether this session is new or not. | 
| protected  boolean | isValidFlag indicating whether this session is valid or not. | 
| protected  long | lastAccessedTimeThe last accessed time for this Session. | 
| protected  java.util.ArrayList | listenersThe session event listeners for this Session. | 
| protected  Manager | managerThe Manager with which this Session is associated. | 
| protected  int | maxInactiveIntervalThe maximum time interval, in seconds, between client requests before the servlet container may invalidate this session. | 
| protected static java.lang.String | NOT_SERIALIZEDThe dummy attribute value serialized when a NotSerializableException is encountered in writeObject(). | 
| protected  java.util.Map | notesInternal notes associated with this session by Catalina components and event listeners. | 
| protected  java.security.Principal | principalThe authenticated Principal associated with this session, if any. | 
| protected static javax.servlet.http.HttpSessionContext | sessionContextThe HTTP session context associated with this session. | 
| protected static StringManager | smThe string manager for this package. | 
| protected  java.beans.PropertyChangeSupport | supportThe property change support for this component. | 
| protected  long | thisAccessedTimeThe current accessed time for this session. | 
| Fields inherited from interface org.apache.catalina.Session | 
|---|
| SESSION_ACTIVATED_EVENT, SESSION_CREATED_EVENT, SESSION_DESTROYED_EVENT, SESSION_PASSIVATED_EVENT | 
| Constructor Summary | |
|---|---|
| StandardSession(Manager manager)Construct a new Session associated with the specified Manager. | |
| Method Summary | |
|---|---|
|  void | access()Update the accessed time information for this session. | 
|  void | activate()Perform internal processing required to activate this session. | 
|  void | addSessionListener(SessionListener listener)Add a session event listener to this component. | 
|  void | endAccess()End the access. | 
| protected  boolean | exclude(java.lang.String name)Deprecated. Use exclude(String, Object). Will be removed in
             Tomcat 9.0.x. | 
| protected  boolean | exclude(java.lang.String name,
        java.lang.Object value)Should the given session attribute be excluded? | 
|  void | expire()Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired. | 
|  void | expire(boolean notify)Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired. | 
| protected  void | fireContainerEvent(Context context,
                   java.lang.String type,
                   java.lang.Object data)Fire container events if the Context implementation is the org.apache.catalina.core.StandardContext. | 
|  void | fireSessionEvent(java.lang.String type,
                 java.lang.Object data)Notify all session event listeners that a particular event has occurred for this Session. | 
|  java.lang.Object | getAttribute(java.lang.String name)Return the object bound with the specified name in this session, or nullif no object is bound with that name. | 
|  java.util.Enumeration | getAttributeNames()Return an EnumerationofStringobjects
 containing the names of the objects bound to this session. | 
|  java.lang.String | getAuthType()Return the authentication type used to authenticate our cached Principal, if any. | 
|  long | getCreationTime()Return the time when this session was created, in milliseconds since midnight, January 1, 1970 GMT. | 
|  java.lang.String | getId()Return the session identifier for this session. | 
|  java.lang.String | getIdInternal()Return the session identifier for this session. | 
|  java.lang.String | getInfo()Return descriptive information about this Session implementation and the corresponding version number, in the format <description>/<version>. | 
|  long | getLastAccessedTime()Return the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. | 
|  long | getLastAccessedTimeInternal()Return the last client access time without invalidation check | 
|  Manager | getManager()Return the Manager within which this Session is valid. | 
|  int | getMaxInactiveInterval()Return the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. | 
|  java.lang.Object | getNote(java.lang.String name)Return the object bound with the specified name to the internal notes for this session, or nullif no such binding exists. | 
|  java.util.Iterator | getNoteNames()Return an Iterator containing the String names of all notes bindings that exist for this session. | 
|  java.security.Principal | getPrincipal()Return the authenticated Principal that is associated with this Session. | 
|  javax.servlet.ServletContext | getServletContext()Return the ServletContext to which this session belongs. | 
|  javax.servlet.http.HttpSession | getSession()Return the HttpSessionfor which this object
 is the facade. | 
|  javax.servlet.http.HttpSessionContext | getSessionContext()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. | 
|  java.lang.Object | getValue(java.lang.String name)Deprecated. As of Version 2.2, this method is replaced by getAttribute() | 
|  java.lang.String[] | getValueNames()Deprecated. As of Version 2.2, this method is replaced by getAttributeNames() | 
|  void | invalidate()Invalidates this session and unbinds any objects bound to it. | 
|  boolean | isAttributeDistributable(java.lang.String name,
                         java.lang.Object value)Does the session implementation support the distributing of the given attribute? This implementation simply checks the value for serializability. | 
|  boolean | isNew()Return trueif the client does not yet know about the
 session, or if the client chooses not to join the session. | 
|  boolean | isValid()Return the isValidflag for this session. | 
| protected  boolean | isValidInternal()Return the isValidflag for this session without any expiration
 check. | 
| protected  java.lang.String[] | keys()Return the names of all currently defined session attributes as an array of Strings. | 
|  void | passivate()Perform the internal processing required to passivate this session. | 
|  void | putValue(java.lang.String name,
         java.lang.Object value)Deprecated. As of Version 2.2, this method is replaced by setAttribute() | 
| protected  void | readObject(java.io.ObjectInputStream stream)Read a serialized version of this session object from the specified object input stream. | 
|  void | readObjectData(java.io.ObjectInputStream stream)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. | 
|  void | recycle()Release all object references, and initialize instance variables, in preparation for reuse of this object. | 
|  void | removeAttribute(java.lang.String name)Remove the object bound with the specified name from this session. | 
|  void | removeAttribute(java.lang.String name,
                boolean notify)Remove the object bound with the specified name from this session. | 
| protected  void | removeAttributeInternal(java.lang.String name,
                        boolean notify)Remove the object bound with the specified name from this session. | 
|  void | removeNote(java.lang.String name)Remove any object bound to the specified name in the internal notes for this session. | 
|  void | removeSessionListener(SessionListener listener)Remove a session event listener from this component. | 
|  void | removeValue(java.lang.String name)Deprecated. As of Version 2.2, this method is replaced by removeAttribute() | 
|  void | setAttribute(java.lang.String name,
             java.lang.Object value)Bind an object to this session, using the specified name. | 
|  void | setAttribute(java.lang.String name,
             java.lang.Object value,
             boolean notify)Bind an object to this session, using the specified name. | 
|  void | setAuthType(java.lang.String authType)Set the authentication type used to authenticate our cached Principal, if any. | 
|  void | setCreationTime(long time)Set the creation time for this session. | 
|  void | setId(java.lang.String id)Set the session identifier for this session. | 
|  void | setId(java.lang.String id,
      boolean notify)Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created. | 
|  void | setManager(Manager manager)Set the Manager within which this Session is valid. | 
|  void | setMaxInactiveInterval(int interval)Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. | 
|  void | setNew(boolean isNew)Set the isNewflag for this session. | 
|  void | setNote(java.lang.String name,
        java.lang.Object value)Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name. | 
|  void | setPrincipal(java.security.Principal principal)Set the authenticated Principal that is associated with this Session. | 
|  void | setValid(boolean isValid)Set the isValidflag for this session. | 
|  void | tellNew()Inform the listeners about the new session. | 
|  java.lang.String | toString()Return a string representation of this object. | 
| protected  void | writeObject(java.io.ObjectOutputStream stream)Write a serialized version of this session object to the specified object output stream. | 
|  void | writeObjectData(java.io.ObjectOutputStream 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. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected static final boolean ACTIVITY_CHECK
protected static final java.lang.String[] EMPTY_ARRAY
protected static final java.lang.String NOT_SERIALIZED
writeObject().
protected java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> attributes
protected transient java.lang.String authType
protected long creationTime
@Deprecated protected static final java.lang.String[] excludedAttributes
Constants.excludedAttributeNames instead. Will be
             removed in Tomcat 9.
protected transient volatile boolean expiring
protected transient StandardSessionFacade facade
protected java.lang.String id
protected static final java.lang.String info
protected volatile long lastAccessedTime
protected transient java.util.ArrayList listeners
protected transient Manager manager
protected int maxInactiveInterval
protected boolean isNew
protected volatile boolean isValid
protected transient java.util.Map notes
protected transient java.security.Principal principal
protected static final StringManager sm
protected static javax.servlet.http.HttpSessionContext sessionContext
protected transient java.beans.PropertyChangeSupport support
protected volatile long thisAccessedTime
protected transient java.util.concurrent.atomic.AtomicInteger accessCount
| Constructor Detail | 
|---|
public StandardSession(Manager manager)
manager - The manager with which this Session is associated| Method Detail | 
|---|
public java.lang.String getAuthType()
getAuthType in interface Sessionpublic void setAuthType(java.lang.String authType)
setAuthType in interface SessionauthType - The new cached authentication typepublic void setCreationTime(long time)
setCreationTime in interface Sessiontime - The new creation timepublic java.lang.String getId()
getId in interface javax.servlet.http.HttpSessiongetId in interface Sessionpublic java.lang.String getIdInternal()
getIdInternal in interface Sessionpublic void setId(java.lang.String id)
setId in interface Sessionid - The new session identifier
public void setId(java.lang.String id,
                  boolean notify)
setId in interface Sessionid - The new session identifiernotify - Should any associated listeners be notified that a new
                      session has been created?public void tellNew()
public java.lang.String getInfo()
<description>/<version>.
getInfo in interface Sessionpublic long getLastAccessedTime()
getLastAccessedTime in interface javax.servlet.http.HttpSessiongetLastAccessedTime in interface Sessionlong
                                        representing the last time
                                        the client sent a request associated
                                        with this session, expressed in
                                        milliseconds since 1/1/1970 GMTpublic long getLastAccessedTimeInternal()
getLastAccessedTimeInternal in interface SessiongetLastAccessedTime().public Manager getManager()
getManager in interface Sessionpublic void setManager(Manager manager)
setManager in interface Sessionmanager - The new Managerpublic int getMaxInactiveInterval()
getMaxInactiveInterval in interface javax.servlet.http.HttpSessiongetMaxInactiveInterval in interface SessionHttpSession.setMaxInactiveInterval(int)public void setMaxInactiveInterval(int interval)
setMaxInactiveInterval in interface javax.servlet.http.HttpSessionsetMaxInactiveInterval in interface Sessioninterval - The new maximum intervalpublic void setNew(boolean isNew)
isNew flag for this session.
setNew in interface SessionisNew - The new value for the isNew flagpublic java.security.Principal getPrincipal()
Authenticator with a means to cache a
 previously authenticated Principal, and avoid potentially expensive
 Realm.authenticate() calls on every request.  If there
 is no current associated Principal, return null.
getPrincipal in interface Sessionpublic void setPrincipal(java.security.Principal principal)
Authenticator with a means to cache a
 previously authenticated Principal, and avoid potentially expensive
 Realm.authenticate() calls on every request.
setPrincipal in interface Sessionprincipal - The new Principal, or null if nonepublic javax.servlet.http.HttpSession getSession()
HttpSession for which this object
 is the facade.
getSession in interface Sessionpublic boolean isValid()
isValid flag for this session.
isValid in interface Sessionpublic void setValid(boolean isValid)
isValid flag for this session.
setValid in interface SessionisValid - The new value for the isValid flagpublic void access()
access in interface Sessionpublic void endAccess()
endAccess in interface Sessionpublic void addSessionListener(SessionListener listener)
addSessionListener in interface Sessionpublic void expire()
expire in interface Sessionpublic void expire(boolean notify)
notify - Should we notify listeners about the demise of
  this session?public void passivate()
public void activate()
public java.lang.Object getNote(java.lang.String name)
null if no such binding exists.
getNote in interface Sessionname - Name of the note to be returnedpublic java.util.Iterator getNoteNames()
getNoteNames in interface Sessionpublic void recycle()
recycle in interface Sessionpublic void removeNote(java.lang.String name)
removeNote in interface Sessionname - Name of the note to be removedpublic void removeSessionListener(SessionListener listener)
removeSessionListener in interface Session
public void setNote(java.lang.String name,
                    java.lang.Object value)
setNote in interface Sessionname - Name to which the object should be boundvalue - Object to be bound to the specified namepublic java.lang.String toString()
toString in class java.lang.Object
public void readObjectData(java.io.ObjectInputStream stream)
                    throws java.lang.ClassNotFoundException,
                           java.io.IOException
stream - The object input stream to read from
java.lang.ClassNotFoundException - if an unknown class is specified
java.io.IOException - if an input/output error occurs
public void writeObjectData(java.io.ObjectOutputStream stream)
                     throws java.io.IOException
stream - The object output stream to write to
java.io.IOException - if an input/output error occurspublic long getCreationTime()
getCreationTime in interface javax.servlet.http.HttpSessiongetCreationTime in interface Sessionlong specifying
                                        when this session was created,
                                        expressed in
                                        milliseconds since 1/1/1970 GMT
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic javax.servlet.ServletContext getServletContext()
getServletContext in interface javax.servlet.http.HttpSessionpublic javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext in interface javax.servlet.http.HttpSessionpublic java.lang.Object getAttribute(java.lang.String name)
null if no object is bound with that name.
getAttribute in interface javax.servlet.http.HttpSessionname - Name of the attribute to be returned
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic java.util.Enumeration getAttributeNames()
Enumeration of String objects
 containing the names of the objects bound to this session.
getAttributeNames in interface javax.servlet.http.HttpSessionEnumeration of
                                String objects specifying the
                                names of all the objects bound to
                                this session
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic java.lang.Object getValue(java.lang.String name)
getAttribute()
null if no object is bound with that name.
getValue in interface javax.servlet.http.HttpSessionname - Name of the value to be returned
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic java.lang.String[] getValueNames()
getAttributeNames()
getValueNames in interface javax.servlet.http.HttpSessionString
                                        objects specifying the
                                        names of all the objects bound to
                                        this session
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic void invalidate()
invalidate in interface javax.servlet.http.HttpSessionjava.lang.IllegalStateException - if this method is called on
  an invalidated sessionpublic boolean isNew()
true if the client does not yet know about the
 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.
isNew in interface javax.servlet.http.HttpSessiontrue if the
                                        server has created a session,
                                        but the client has not yet joined
java.lang.IllegalStateException - if this method is called on an
  invalidated session
public void putValue(java.lang.String name,
                     java.lang.Object value)
setAttribute()
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueBound() on the object.
putValue in interface javax.servlet.http.HttpSessionname - Name to which the object is bound, cannot be nullvalue - Object to be bound, cannot be null
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic void removeAttribute(java.lang.String name)
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueUnbound() on the object.
removeAttribute in interface javax.servlet.http.HttpSessionname - Name of the object to remove from this session.
java.lang.IllegalStateException - if this method is called on an
  invalidated session
public void removeAttribute(java.lang.String name,
                            boolean notify)
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueUnbound() on the object.
name - Name of the object to remove from this session.notify - Should we notify interested listeners that this
  attribute is being removed?
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionpublic void removeValue(java.lang.String name)
removeAttribute()
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueUnbound() on the object.
removeValue in interface javax.servlet.http.HttpSessionname - Name of the object to remove from this session.
java.lang.IllegalStateException - if this method is called on an
  invalidated session
public void setAttribute(java.lang.String name,
                         java.lang.Object value)
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueBound() on the object.
setAttribute in interface javax.servlet.http.HttpSessionname - Name to which the object is bound, cannot be nullvalue - Object to be bound, cannot be null
java.lang.IllegalArgumentException - if an attempt is made to add a
  non-serializable object in an environment marked distributable.
java.lang.IllegalStateException - if this method is called on an
  invalidated session
public void setAttribute(java.lang.String name,
                         java.lang.Object value,
                         boolean notify)
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueBound() on the object.
name - Name to which the object is bound, cannot be nullvalue - Object to be bound, cannot be nullnotify - whether to notify session listeners
java.lang.IllegalArgumentException - if an attempt is made to add a
  non-serializable object in an environment marked distributable.
java.lang.IllegalStateException - if this method is called on an
  invalidated sessionprotected boolean isValidInternal()
isValid flag for this session without any expiration
 check.
public boolean isAttributeDistributable(java.lang.String name,
                                        java.lang.Object value)
IllegalArgumentException thrown if the proposed attribute is
 not distributable.
 
 Note that the Manager implementation may further restrict which
 attributes are distributed but a Manager level restriction should
 not trigger an IllegalArgumentException in
 HttpSession.setAttribute(String, Object)
 
This implementation simply checks the value for serializability. Sub-classes might use other distribution technology not based on serialization and can override this check.
isAttributeDistributable in interface Sessionname - The attribute namevalue - The attribute value
true if distribution is supported, otherwise false
protected void readObject(java.io.ObjectInputStream stream)
                   throws java.lang.ClassNotFoundException,
                          java.io.IOException
IMPLEMENTATION NOTE: The reference to the owning Manager is not restored by this method, and must be set explicitly.
stream - The input stream to read from
java.lang.ClassNotFoundException - if an unknown class is specified
java.io.IOException - if an input/output error occurs
protected void writeObject(java.io.ObjectOutputStream stream)
                    throws java.io.IOException
 IMPLEMENTATION NOTE:  The owning Manager will not be stored
 in the serialized representation of this Session.  After calling
 readObject(), you must set the associated Manager
 explicitly.
 
 IMPLEMENTATION NOTE:  Any attribute that is not Serializable
 will be unbound from the session, with appropriate actions if it
 implements HttpSessionBindingListener.  If you do not want any such
 attributes, be sure the distributable property of the
 associated Manager is set to true.
stream - The output stream to write to
java.io.IOException - if an input/output error occurs@Deprecated protected boolean exclude(java.lang.String name)
exclude(String, Object). Will be removed in
             Tomcat 9.0.x.
name - the attribute's name
protected boolean exclude(java.lang.String name,
                          java.lang.Object value)
isAttributeDistributable(String, Object) which is kept
       separate to support the checks required in
       setAttribute(String, Object, boolean)
name - The attribute namevalue - The attribute value
true if the attribute should be excluded from
         distribution, otherwise false
protected void fireContainerEvent(Context context,
                                  java.lang.String type,
                                  java.lang.Object data)
                           throws java.lang.Exception
org.apache.catalina.core.StandardContext.
context - Context for which to fire eventstype - Event typedata - Event data
java.lang.Exception - occurred during event firing
public void fireSessionEvent(java.lang.String type,
                             java.lang.Object data)
type - Event typedata - Event dataprotected java.lang.String[] keys()
protected void removeAttributeInternal(java.lang.String name,
                                       boolean notify)
 After this method executes, and if the object implements
 HttpSessionBindingListener, the container calls
 valueUnbound() on the object.
name - Name of the object to remove from this session.notify - Should we notify interested listeners that this
  attribute is being removed?| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||