Class HttpSessionImpl
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.coherence.servlet.api23.HttpSessionImpl
-
- All Implemented Interfaces:
javax.servlet.http.HttpSession
public class HttpSessionImpl extends Base implements javax.servlet.http.HttpSession
This is the HttpSession implementation that supports clustering.- Version:
- Coherence 2.3
- Author:
- cp 2003.07.24
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Constructor Summary
Constructors Constructor Description HttpSessionImpl(SessionHelper helper, HttpSessionCollection collection)
Construct a Coherence HTTP session object for a new session.HttpSessionImpl(SessionHelper helper, HttpSessionCollection collection, String sId)
Construct a Coherence HTTP session object for an existing session.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected HttpSessionModel
ensureActiveModel()
Obtain an "active" HttpSessionModel for this session.protected HttpSessionModel
ensureUsableModel()
Obtain a "usable" HttpSessionModel for this session, which may or may not be active.protected void
enter()
Ensure ownership of the session.protected void
exit()
Release ownership of the session.Object
getAttribute(String sName)
Returns the object bound with the specified name in this session, ornull
if no object is bound under the name.Enumeration
getAttributeNames()
Returns anEnumeration
ofString
objects containing the names of all the objects bound to this session.protected HttpSessionCollection
getCollection()
Obtain the HttpSessionCollection.long
getCreationTime()
Returns the creation time for this session.protected String
getDescription()
Returns a string representation of this object's attributes.String
getId()
Returns the session identifier for this session.long
getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT.int
getMaxInactiveInterval()
Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.javax.servlet.ServletContext
getServletContext()
Returns the ServletContext to which this session belongs.javax.servlet.http.HttpSessionContext
getSessionContext()
Deprecated.As of Version 2.1, this method is deprecated and has no replacement.protected SessionHelper
getSessionHelper()
Get the SessionHelper for this ServletContext wrapper.Object
getValue(String sName)
Deprecated.As of Version 2.2, this method is replaced bygetAttribute(String)
.String[]
getValueNames()
Deprecated.As of Version 2.2, this method is replaced bygetAttributeNames()
void
invalidate()
Invalidates this session then unbinds any objects bound to it.boolean
isNew()
Returnstrue
if the client does not yet know about the session or if the client chooses not to join the session.void
putValue(String sName, Object oValue)
Deprecated.As of Version 2.2, this method is replaced bysetAttribute(String, Object)
void
removeAttribute(String sName)
Removes the object bound with the specified name from this session.void
removeValue(String sName)
Deprecated.As of Version 2.2, this method is replaced byremoveAttribute(String)
void
setAttribute(String sName, Object oValue)
Binds an object to this session, using the name specified.void
setMaxInactiveInterval(int cSeconds)
Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.String
toString()
Returns a string representation of the object.-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Constructor Detail
-
HttpSessionImpl
public HttpSessionImpl(SessionHelper helper, HttpSessionCollection collection)
Construct a Coherence HTTP session object for a new session.- Parameters:
helper
- the application's session helpercollection
- the HttpSessionCollection that this session will use to create and manage its session model
-
HttpSessionImpl
public HttpSessionImpl(SessionHelper helper, HttpSessionCollection collection, String sId)
Construct a Coherence HTTP session object for an existing session.- Parameters:
helper
- the application's session helpercollection
- the HttpSessionCollection that this session will use to access and manage its session modelsId
- the session ID that this session will represent
-
-
Method Detail
-
getAttribute
public Object getAttribute(String sName)
Returns the object bound with the specified name in this session, ornull
if no object is bound under the name.- Specified by:
getAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- a string specifying the name of the object- Returns:
- the object with the specified name
- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
getAttributeNames
public Enumeration getAttributeNames()
Returns anEnumeration
ofString
objects containing the names of all the objects bound to this session.- Specified by:
getAttributeNames
in interfacejavax.servlet.http.HttpSession
- Returns:
- an
Enumeration
ofString
objects specifying the names of all the objects bound to this session - Throws:
IllegalStateException
- if this method is called on an invalidated session
-
getCreationTime
public long getCreationTime()
Returns the creation time for this session.- Specified by:
getCreationTime
in interfacejavax.servlet.http.HttpSession
- Returns:
- the creation time for this session
-
getId
public String getId()
Returns the session identifier for this session.- Specified by:
getId
in interfacejavax.servlet.http.HttpSession
- Returns:
- the session identifier for this session.
-
getLastAccessedTime
public long getLastAccessedTime()
Returns 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 interfacejavax.servlet.http.HttpSession
- Returns:
- 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
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
Returns 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 interfacejavax.servlet.http.HttpSession
- Returns:
- 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
-
getServletContext
public javax.servlet.ServletContext getServletContext()
Returns the ServletContext to which this session belongs.- Specified by:
getServletContext
in interfacejavax.servlet.http.HttpSession
- Returns:
- The ServletContext object for the web application
- Since:
- Servlet 2.3
-
getSessionContext
public 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.Get the HttpSessionContext.- Specified by:
getSessionContext
in interfacejavax.servlet.http.HttpSession
- Returns:
- an HttpSessionContext object
-
getValue
public Object getValue(String sName)
Deprecated.As of Version 2.2, this method is replaced bygetAttribute(String)
.Returns the object bound with the specified name in this session, ornull
if no object is bound under the name.- Specified by:
getValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- a string specifying the name of the object- Returns:
- the object with the specified name
- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
getValueNames
public String[] getValueNames()
Deprecated.As of Version 2.2, this method is replaced bygetAttributeNames()
Returns an array ofString
objects specifying the names of all the objects bound to this session.- Specified by:
getValueNames
in interfacejavax.servlet.http.HttpSession
- Returns:
- an array of
String
objects specifying the names of all the objects bound to this session - Throws:
IllegalStateException
- if this method is called on an invalidated session
-
invalidate
public void invalidate()
Invalidates this session then unbinds any objects bound to it.- Specified by:
invalidate
in interfacejavax.servlet.http.HttpSession
- Throws:
IllegalStateException
- if this method is called on an already invalidated session
-
isNew
public boolean isNew()
Returnstrue
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 had disabled the use of cookies, then a session would be new on each request.- Specified by:
isNew
in interfacejavax.servlet.http.HttpSession
- Returns:
true
if the server has created a session, but the client has not yet joined- Throws:
IllegalStateException
- if this method is called on an already invalidated session
-
putValue
public void putValue(String sName, Object oValue)
Deprecated.As of Version 2.2, this method is replaced bysetAttribute(String, Object)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.If the value passed in is null, this has the same effect as calling
removeAttribute()
.- Specified by:
putValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- the name to which the object is bound; cannot be nulloValue
- the object to be bound; cannot be null- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
removeAttribute
public void removeAttribute(String sName)
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.- Specified by:
removeAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- the name of the object to remove from this session- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
removeValue
public void removeValue(String sName)
Deprecated.As of Version 2.2, this method is replaced byremoveAttribute(String)
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.- Specified by:
removeValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- the name of the object to remove from this session- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
setAttribute
public void setAttribute(String sName, Object oValue)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.If the value passed in is null, this has the same effect as calling
removeAttribute()
.- Specified by:
setAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
sName
- the name to which the object is bound; cannot be nulloValue
- the object to be bound- Throws:
IllegalStateException
- if this method is called on an invalidated session
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int cSeconds)
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 interfacejavax.servlet.http.HttpSession
- Parameters:
cSeconds
- the new maximum interval
-
toString
public String toString()
Returns a string representation of the object.
-
getDescription
protected String getDescription()
Returns a string representation of this object's attributes.- Returns:
- a string representation of this object's attributes
-
ensureUsableModel
protected HttpSessionModel ensureUsableModel()
Obtain a "usable" HttpSessionModel for this session, which may or may not be active.- Returns:
- a usable HttpSessionModel for this session object
- Throws:
IllegalStateException
- if a usable model cannot be obtained, for example if the session ID does not exist in the cluster
-
ensureActiveModel
protected HttpSessionModel ensureActiveModel()
Obtain an "active" HttpSessionModel for this session.- Returns:
- an active HttpSessionModel for this session object
- Throws:
IllegalStateException
- if a usable model cannot be obtained, for example if the session ID does not exist in the cluster
-
enter
protected void enter()
Ensure ownership of the session.
-
exit
protected void exit()
Release ownership of the session.
-
getSessionHelper
protected SessionHelper getSessionHelper()
Get the SessionHelper for this ServletContext wrapper.- Returns:
- the SessionHelper for this ServletContext wrapper
-
getCollection
protected HttpSessionCollection getCollection()
Obtain the HttpSessionCollection.- Returns:
- the HttpSessionCollection that manages the session models
-
-