Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.catalina.session.StandardSession
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.
Please note two sessions are only considered equal if they are
"reference-equal." There is no equals() method implementation.
Field Summary | |
protected static String[] |
|
protected static String |
|
protected int |
|
protected HashMap |
|
protected String |
|
protected Method |
|
protected static Class[] |
|
protected long |
|
protected int |
|
protected boolean |
|
protected StandardSessionFacade |
|
protected String |
|
protected static String |
|
protected boolean |
|
protected boolean |
|
protected long |
|
protected ArrayList |
|
protected Manager |
|
protected int |
|
protected HashMap |
|
protected Principal |
|
protected static HttpSessionContext |
|
protected static StringManager |
|
protected PropertyChangeSupport |
|
protected long |
|
Fields inherited from interface org.apache.catalina.Session | |
SESSION_CREATED_EVENT , SESSION_DESTROYED_EVENT |
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
protected void | |
protected boolean |
|
void |
|
void |
|
protected void |
|
void |
|
Object |
|
protected Object |
|
Enumeration |
|
String |
|
long |
|
String |
|
String |
|
long |
|
Manager |
|
int |
|
Object |
|
Iterator |
|
Principal |
|
ServletContext |
|
HttpSession |
|
HttpSessionContext |
|
Object |
|
String[] |
|
void |
|
boolean |
|
boolean |
|
protected String[] |
|
protected void |
|
protected void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
String |
|
protected void |
|
void |
|
protected static final String[] EMPTY_ARRAY
Type array.
protected static final String NOT_SERIALIZED
The dummy attribute value serialized when a NotSerializableException is encountered inwriteObject()
.
protected int accessCount
The access count for this session.
protected HashMap attributes
The collection of user data attributes associated with this Session.
protected String authType
The authentication type used to authenticate our cached Principal, if any. NOTE: This value is not included in the serialized version of this object.
protected Method containerEventMethod
Thejava.lang.Method
for thefireContainerEvent()
method of theorg.apache.catalina.core.StandardContext
method, if our Context implementation is of this class. This value is computed dynamically the first time it is needed, or after a session reload (since it is declared transient).
protected static final Class[] containerEventTypes
The method signature for thefireContainerEvent
method.
protected long creationTime
The time this session was created, in milliseconds since midnight, January 1, 1970 GMT.
protected int debug
The debugging detail level for this component. NOTE: This value is not included in the serialized version of this object.
protected boolean expiring
We are currently processing a session expiration, so bypass certain IllegalStateException tests. NOTE: This value is not included in the serialized version of this object.
protected StandardSessionFacade facade
The facade associated with this session. NOTE: This value is not included in the serialized version of this object.
protected String id
The session identifier of this Session.
protected static final String info
Descriptive information describing this Session implementation.
protected boolean isNew
Flag indicating whether this session is new or not.
protected boolean isValid
Flag indicating whether this session is valid or not.
protected long lastAccessedTime
The last accessed time for this Session.
protected ArrayList listeners
The session event listeners for this Session.
protected int maxInactiveInterval
The maximum time interval, in seconds, between client requests before the servlet container may invalidate this session. A negative time indicates that the session should never time out.
protected HashMap notes
Internal notes associated with this session by Catalina components and event listeners. IMPLEMENTATION NOTE: This object is not saved and restored across session serializations!
protected Principal principal
The authenticated Principal associated with this session, if any. IMPLEMENTATION NOTE: This object is not saved and restored across session serializations!
protected static HttpSessionContext sessionContext
The HTTP session context associated with this session.
protected PropertyChangeSupport support
The property change support for this component. NOTE: This value is not included in the serialized version of this object.
protected long thisAccessedTime
The current accessed time for this session.
public StandardSession(Manager manager)
Construct a new Session associated with the specified Manager.
- Parameters:
manager
- The manager with which this Session is associated
public void access()
Update the accessed time information for this session. This method should be called by the context when a request comes in for a particular session, even if the application does not reference it.
public void activate()
Perform internal processing required to activate this session.
public void addSessionListener(SessionListener listener)
Add a session event listener to this component.
- Specified by:
- addSessionListener in interface Session
protected void evaluateIfValid()
protected boolean exclude(String name)
Exclude attribute that cannot be serialized.
- Parameters:
name
- the attribute's name
public void expire()
Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.
public void expire(boolean notify)
Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.
- Parameters:
notify
- Should we notify listeners about the demise of this session?
protected void fireContainerEvent(Context context, String type, Object data) throws Exception
Fire container events if the Context implementation is theorg.apache.catalina.core.StandardContext
.
- Parameters:
context
- Context for which to fire eventstype
- Event typedata
- Event data
public void fireSessionEvent(String type, Object data)
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.
- Parameters:
type
- Event typedata
- Event data
public Object getAttribute(String name)
Return the object bound with the specified name in this session, ornull
if no object is bound with that name.
- Parameters:
name
- Name of the attribute to be returned
protected Object getAttributeInternal(String name)
Return the value of an attribute without a check for validity.
public Enumeration getAttributeNames()
Return anEnumeration
ofString
objects containing the names of the objects bound to this session.
public String getAuthType()
Return the authentication type used to authenticate our cached Principal, if any.
- Specified by:
- getAuthType in interface Session
public long getCreationTime()
Return the time when this session was created, in milliseconds since midnight, January 1, 1970 GMT.
- Specified by:
- getCreationTime in interface Session
public String getId()
Return the session identifier for this session.
public String getInfo()
Return descriptive information about this Session implementation and the corresponding version number, in the format<description>/<version>
.
public 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. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
- Specified by:
- getLastAccessedTime in interface Session
public Manager getManager()
Return the Manager within which this Session is valid.
- Specified by:
- getManager in interface Session
public int getMaxInactiveInterval()
Return 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.
- Specified by:
- getMaxInactiveInterval in interface Session
public Object getNote(String name)
Return the object bound with the specified name to the internal notes for this session, ornull
if no such binding exists.
- Parameters:
name
- Name of the note to be returned
public Iterator getNoteNames()
Return an Iterator containing the String names of all notes bindings that exist for this session.
- Specified by:
- getNoteNames in interface Session
public Principal getPrincipal()
Return the authenticated Principal that is associated with this Session. This provides anAuthenticator
with a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()
calls on every request. If there is no current associated Principal, returnnull
.
- Specified by:
- getPrincipal in interface Session
public ServletContext getServletContext()
Return the ServletContext to which this session belongs.
public HttpSession getSession()
Return theHttpSession
for which this object is the facade.
- Specified by:
- getSession in interface Session
public 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.
Return the session context with which this session is associated.
public Object getValue(String name)
Deprecated. As of Version 2.2, this method is replaced by
getAttribute()
Return the object bound with the specified name in this session, ornull
if no object is bound with that name.
- Parameters:
name
- Name of the value to be returned
public String[] getValueNames()
Deprecated. As of Version 2.2, this method is replaced by
getAttributeNames()
Return the set of names of objects bound to this session. If there are no such objects, a zero-length array is returned.
public void invalidate()
Invalidates this session and unbinds any objects bound to it.
public boolean isNew()
Returntrue
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.
public boolean isValid()
Return theisValid
flag for this session.
protected String[] keys()
Return the names of all currently defined session attributes as an array of Strings. If there are no defined attributes, a zero-length array is returned.
protected void log(String message)
Log a message on the Logger associated with our Manager (if any).
- Parameters:
message
- Message to be logged
protected void log(String message, Throwable throwable)
Log a message on the Logger associated with our Manager (if any).
- Parameters:
message
- Message to be loggedthrowable
- Associated exception
public void passivate()
Perform the internal processing required to passivate this session.
public void putValue(String name, Object value)
Deprecated. As of Version 2.2, this method is replaced by
setAttribute()
Bind an object to this session, using the specified name. If an object of the same name is already bound to this session, the object is replaced. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueBound()
on the object.
- Parameters:
name
- Name to which the object is bound, cannot be nullvalue
- Object to be bound, cannot be null
protected void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException
Read a serialized version of this session object from the specified object input stream. IMPLEMENTATION NOTE: The reference to the owning Manager is not restored by this method, and must be set explicitly.
- Parameters:
stream
- The input stream to read from
public void readObjectData(ObjectInputStream stream) throws ClassNotFoundException, IOException
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.
- Parameters:
stream
- The object input stream to read from
public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
public void removeAttribute(String name)
Remove the object bound with the specified name from this session. If the session does not have an object bound with this name, this method does nothing. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueUnbound()
on the object.
- Parameters:
name
- Name of the object to remove from this session.
public void removeAttribute(String name, boolean notify)
Remove the object bound with the specified name from this session. If the session does not have an object bound with this name, this method does nothing. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueUnbound()
on the object.
- Parameters:
name
- Name of the object to remove from this session.notify
- Should we notify interested listeners that this attribute is being removed?
protected void removeAttributeInternal(String name, boolean notify)
Remove the object bound with the specified name from this session. If the session does not have an object bound with this name, this method does nothing. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueUnbound()
on the object.
- Parameters:
name
- Name of the object to remove from this session.notify
- Should we notify interested listeners that this attribute is being removed?
public void removeNote(String name)
Remove any object bound to the specified name in the internal notes for this session.
- Specified by:
- removeNote in interface Session
- Parameters:
name
- Name of the note to be removed
public void removeSessionListener(SessionListener listener)
Remove a session event listener from this component.
- Specified by:
- removeSessionListener in interface Session
public void removeValue(String name)
Deprecated. As of Version 2.2, this method is replaced by
removeAttribute()
Remove the object bound with the specified name from this session. If the session does not have an object bound with this name, this method does nothing. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueUnbound()
on the object.
- Parameters:
name
- Name of the object to remove from this session.
public void setAttribute(String name, Object value)
Bind an object to this session, using the specified name. If an object of the same name is already bound to this session, the object is replaced. After this method executes, and if the object implementsHttpSessionBindingListener
, the container callsvalueBound()
on the object.
- Parameters:
name
- Name to which the object is bound, cannot be nullvalue
- Object to be bound, cannot be null
public void setAuthType(String authType)
Set the authentication type used to authenticate our cached Principal, if any.
- Specified by:
- setAuthType in interface Session
- Parameters:
authType
- The new cached authentication type
public void setCreationTime(long time)
Set the creation time for this session. This method is called by the Manager when an existing Session instance is reused.
- Specified by:
- setCreationTime in interface Session
- Parameters:
time
- The new creation time
public void setId(String id)
Set the session identifier for this session.
- Parameters:
id
- The new session identifier
public void setManager(Manager manager)
Set the Manager within which this Session is valid.
- Specified by:
- setManager in interface Session
- Parameters:
manager
- The new Manager
public void setMaxInactiveInterval(int interval)
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.
- Specified by:
- setMaxInactiveInterval in interface Session
- Parameters:
interval
- The new maximum interval
public void setNew(boolean isNew)
Set theisNew
flag for this session.
- Parameters:
isNew
- The new value for theisNew
flag
public void setNote(String name, Object value)
Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.
- Parameters:
name
- Name to which the object should be boundvalue
- Object to be bound to the specified name
public void setPrincipal(Principal principal)
Set the authenticated Principal that is associated with this Session. This provides anAuthenticator
with a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()
calls on every request.
- Specified by:
- setPrincipal in interface Session
- Parameters:
principal
- The new Principal, ornull
if none
public void setValid(boolean isValid)
Set theisValid
flag for this session.
- Parameters:
isValid
- The new value for theisValid
flag
public void tellNew()
Inform the listeners about the new session.
public String toString()
Return a string representation of this object.
protected void writeObject(ObjectOutputStream stream) throws IOException
Write a serialized version of this session object to the specified object output stream. IMPLEMENTATION NOTE: The owning Manager will not be stored in the serialized representation of this Session. After callingreadObject()
, 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 thedistributable
property of the associated Manager is set totrue
.
- Parameters:
stream
- The output stream to write to
public void writeObjectData(ObjectOutputStream stream) throws IOException
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.
- Parameters:
stream
- The object output stream to write to