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 HttpSessionModelensureActiveModel()Obtain an "active" HttpSessionModel for this session.protected HttpSessionModelensureUsableModel()Obtain a "usable" HttpSessionModel for this session, which may or may not be active.protected voidenter()Ensure ownership of the session.protected voidexit()Release ownership of the session.ObjectgetAttribute(String sName)Returns the object bound with the specified name in this session, ornullif no object is bound under the name.EnumerationgetAttributeNames()Returns anEnumerationofStringobjects containing the names of all the objects bound to this session.protected HttpSessionCollectiongetCollection()Obtain the HttpSessionCollection.longgetCreationTime()Returns the creation time for this session.protected StringgetDescription()Returns a string representation of this object's attributes.StringgetId()Returns the session identifier for this session.longgetLastAccessedTime()Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT.intgetMaxInactiveInterval()Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.javax.servlet.ServletContextgetServletContext()Returns the ServletContext to which this session belongs.javax.servlet.http.HttpSessionContextgetSessionContext()Deprecated.As of Version 2.1, this method is deprecated and has no replacement.protected SessionHelpergetSessionHelper()Get the SessionHelper for this ServletContext wrapper.ObjectgetValue(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()voidinvalidate()Invalidates this session then unbinds any objects bound to it.booleanisNew()Returnstrueif the client does not yet know about the session or if the client chooses not to join the session.voidputValue(String sName, Object oValue)Deprecated.As of Version 2.2, this method is replaced bysetAttribute(String, Object)voidremoveAttribute(String sName)Removes the object bound with the specified name from this session.voidremoveValue(String sName)Deprecated.As of Version 2.2, this method is replaced byremoveAttribute(String)voidsetAttribute(String sName, Object oValue)Binds an object to this session, using the name specified.voidsetMaxInactiveInterval(int cSeconds)Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.StringtoString()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, ornullif no object is bound under the name.- Specified by:
getAttributein 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 anEnumerationofStringobjects containing the names of all the objects bound to this session.- Specified by:
getAttributeNamesin interfacejavax.servlet.http.HttpSession- Returns:
- an
EnumerationofStringobjects 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:
getCreationTimein interfacejavax.servlet.http.HttpSession- Returns:
- the creation time for this session
-
getId
public String getId()
Returns the session identifier for this session.- Specified by:
getIdin 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:
getLastAccessedTimein 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:
getMaxInactiveIntervalin 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:
getServletContextin 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:
getSessionContextin 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, ornullif no object is bound under the name.- Specified by:
getValuein 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 ofStringobjects specifying the names of all the objects bound to this session.- Specified by:
getValueNamesin interfacejavax.servlet.http.HttpSession- Returns:
- an array of
Stringobjects 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:
invalidatein interfacejavax.servlet.http.HttpSession- Throws:
IllegalStateException- if this method is called on an already invalidated session
-
isNew
public boolean isNew()
Returnstrueif 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:
isNewin interfacejavax.servlet.http.HttpSession- Returns:
trueif 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:
putValuein 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:
removeAttributein 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:
removeValuein 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:
setAttributein 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:
setMaxInactiveIntervalin 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
-
-