public class SessionImpl extends java.lang.Object implements HttpSession, CacheListener
Modifier and Type | Field and Description |
---|---|
protected SessionManager |
_manager |
protected java.util.Map<java.lang.String,java.lang.Object> |
_values |
Constructor and Description |
---|
SessionImpl(SessionManager manager,
java.lang.String id,
long creationTime)
Create a new session object.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
createValueMap()
Create the map used to objectStore values.
|
void |
finishRequest()
Cleaning up session stuff at the end of a request.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the named attribute from the session.
|
java.util.Enumeration |
getAttributeNames()
Return an enumeration of all the sessions' attribute names.
|
long |
getCreationTime()
Returns the time the session was created.
|
java.lang.String |
getId()
Returns the session identifier.
|
long |
getLastAccessedTime()
Returns the last objectAccess time.
|
int |
getLastSaveLength() |
SessionManager |
getManager()
Returns the session manager.
|
int |
getMaxInactiveInterval()
Returns the time the session is allowed to be alive.
|
ServletContext |
getServletContext()
Returns the servlet context.
|
HttpSessionContext |
getSessionContext()
Deprecated.
|
protected int |
getUseCount() |
java.lang.Object |
getValue(java.lang.String name)
Deprecated.
|
java.lang.String[] |
getValueNames()
Deprecated.
|
void |
invalidate()
Invalidates the session, called by user code.
|
void |
invalidateLogout()
Invalidates a session based on a logout.
|
void |
invalidateRemote()
Invalidates the session, called by user code.
|
boolean |
isEmpty()
Returns true if the session is empty.
|
boolean |
isInUse()
Returns true if the session is in use.
|
boolean |
isNew()
Returns true if the session is new.
|
boolean |
isTimeout() |
boolean |
isValid()
Returns true if the session is valid.
|
boolean |
load(boolean isNew)
Loads the session.
|
boolean |
load(SessionDeserializer in)
Loads the object from the input stream.
|
void |
passivate()
Passivates the session.
|
void |
putValue(java.lang.String name,
java.lang.Object value)
Deprecated.
|
void |
removeAttribute(java.lang.String name)
Remove a session attribute.
|
void |
removeEvent()
Callback when the session is removed from the session cache, generally
because the session cache is full.
|
void |
removeValue(java.lang.String name)
Deprecated.
|
void |
save()
Saves changes to the session.
|
void |
saveAfterRequest()
Flush changes after a request completes.
|
void |
saveBeforeFlush()
Save changes before any flush.
|
void |
saveBeforeHeaders()
Flush changes before the headers.
|
void |
setAccessTime(long accessTime) |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets a session attribute.
|
void |
setMaxInactiveInterval(int value)
Sets the maximum time a session is allowed to be alive.
|
void |
store(SessionSerializer out)
Saves the object to the input stream.
|
void |
timeout()
Called by the session manager for a session timeout
|
java.lang.String |
toString() |
void |
unbind()
Cleans up the session.
|
protected SessionManager _manager
protected java.util.Map<java.lang.String,java.lang.Object> _values
public SessionImpl(SessionManager manager, java.lang.String id, long creationTime)
manager
- the owning session manager.id
- the session identifier.creationTime
- the time in milliseconds when the session was created.protected java.util.Map<java.lang.String,java.lang.Object> createValueMap()
public long getCreationTime()
getCreationTime
in interface HttpSession
public java.lang.String getId()
getId
in interface HttpSession
public long getLastAccessedTime()
getLastAccessedTime
in interface HttpSession
public int getMaxInactiveInterval()
getMaxInactiveInterval
in interface HttpSession
public void setMaxInactiveInterval(int value)
setMaxInactiveInterval
in interface HttpSession
value
- time allowed to live in secondspublic HttpSessionContext getSessionContext()
getSessionContext
in interface HttpSession
public ServletContext getServletContext()
getServletContext
in interface HttpSession
public SessionManager getManager()
public boolean isNew()
isNew
in interface HttpSession
public boolean isValid()
public boolean isTimeout()
public boolean isEmpty()
public boolean isInUse()
protected int getUseCount()
public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface HttpSession
name
- of the attribute.public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface HttpSession
name
- the name of the attributevalue
- the value of the attributepublic void removeAttribute(java.lang.String name)
removeAttribute
in interface HttpSession
name
- the name of the attribute to objectRemovepublic java.util.Enumeration getAttributeNames()
getAttributeNames
in interface HttpSession
public java.lang.Object getValue(java.lang.String name)
getValue
in interface HttpSession
public void putValue(java.lang.String name, java.lang.Object value)
putValue
in interface HttpSession
public void removeValue(java.lang.String name)
removeValue
in interface HttpSession
public java.lang.String[] getValueNames()
getValueNames
in interface HttpSession
public void setAccessTime(long accessTime)
public int getLastSaveLength()
public void finishRequest()
If the session data has changed and we have persistent sessions, save the session. However, if save-on-shutdown is true, only save on a server shutdown.
public boolean load(boolean isNew)
public boolean load(SessionDeserializer in) throws java.io.IOException
java.io.IOException
public final void saveBeforeFlush()
public final void saveBeforeHeaders()
public final void saveAfterRequest()
public final void save()
public void passivate()
public void store(SessionSerializer out) throws java.io.IOException
java.io.IOException
public void invalidate()
invalidate
in interface HttpSession
public void timeout()
public void removeEvent()
removeEvent
in interface CacheListener
public void invalidateLogout()
public void invalidateRemote()
public void unbind()
public java.lang.String toString()
toString
in class java.lang.Object