|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.coherence.servlet.AbstractHttpSessionCollection
public abstract class AbstractHttpSessionCollection
An abstract base class from which implementations of HttpSessionCollection can be more easily built.
Nested Class Summary | |
---|---|
static class |
AbstractHttpSessionCollection.ExitAgent
This agent is used to request the other servers in the cluster to unlock the specified session ID. |
static class |
AbstractHttpSessionCollection.ExitObserver
This InvocationObserver waits for an ExitAgent to report back that some server in the cluster did have the specified session id locked. |
static class |
AbstractHttpSessionCollection.SimpleDistributedController
A simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed in a distributed manner. |
static class |
AbstractHttpSessionCollection.SimpleHybridController
A simple implementation of the SessionDistributionController interface that forces all sessions and serializable attributes to be managed in a distributed manner. |
static class |
AbstractHttpSessionCollection.SimpleLocalController
A simple implementation of the SessionDistributionController interface that forces all sessions (and thus their attributes) to be managed locally. |
Nested classes/interfaces inherited from interface com.tangosol.coherence.servlet.HttpSessionCollection |
---|
HttpSessionCollection.SessionDistributionController |
Field Summary | |
---|---|
static String |
CACHENAME_DEATHCERTS
The name of the clustered cache that stores the IDs of "recently departed" sessions. |
static String |
CACHENAME_LOCAL_ATTRIBUTES
The name of the local cache that stores the session attributes that are not distributed (if there is a distribution controller or attributes are allowed to become local when serialization fails). |
static String |
CACHENAME_LOCAL_SESSIONS
The name of the local cache that stores the sessions that are not yet distributed (if there is a distribution controller). |
static String |
CACHENAME_SESSIONS
The name of the clustered cache that stores the sessions. |
static String |
CTX_INIT_ALLOW_LOCAL_ATTRIBUTES
The configuration property that specifies whether non-serializable attributes should be preserved as local. |
static String |
CTX_INIT_CACHENAME_DEATHCERTS
The configuration property that overrides the name of the clustered cache that stores the IDs of "recently departed" sessions. |
static String |
CTX_INIT_CACHENAME_LOCAL_ATTRIBUTES
The configuration property that overrides the name of the local cache that stores non-distributed session attributes when the SessionDistributionController option is implemented. |
static String |
CTX_INIT_CACHENAME_LOCAL_SESSIONS
The configuration property that overrides the name of the local cache that stores non-distributed sessions when the SessionDistributionController option is implemented. |
static String |
CTX_INIT_CACHENAME_SESSIONS
The configuration property that overrides the name of the clustered cache that stores the sessions. |
static String |
CTX_INIT_CONTROLLER_CLASS
The configuration property that specifies an implementation of the SessionDistributionController interface to use. |
static String |
CTX_INIT_DAEMON_ASSUME_LOCALITY
True to assume that the sessions in the cache are split across only the servers that are doing reaping. |
static String |
CTX_INIT_SERVICENAME_OWNERSHIP
The configuration property that specifies the name of the invocation service that will be used to manage sticky session ownership. |
static String |
CTX_INIT_SESSION_EXPIRE_SECS
The configuration property that overrides the session expirty time. |
static String |
CTX_INIT_SESSION_ID_LENGTH
The configuration property that overrides the session id length. |
static String |
CTX_INIT_SESSION_STICKY
The configuration property that specifies whether sticky sessions optimizations will be used. |
static String |
CTX_INIT_SESSION_STRICT_SPEC
The configuration property that specifies strict spec adherence. |
static String |
CTX_INIT_SESSION_THREAD_LOCK
The configuration property that specifies thread level session locking. |
static String |
SERVICENAME_OWNERSHIP
The name of the clustered invocation service that manages sticky session ownership. |
Constructor Summary | |
---|---|
AbstractHttpSessionCollection()
Default constructor (required). |
Method Summary | |
---|---|
void |
activate(String sId,
HttpSession session)
Move the session into an active state, if it is not already. |
void |
addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Sign up the specified listener to receive HttpSessionBindingEvent objects. |
void |
addHttpSessionListener(HttpSessionListener listener)
Sign up the specified listener to receive HttpSessionEvent objects. |
HttpSessionModel |
create(HttpSession session)
This method creates a new session, returning the session model for the new session. |
void |
destroy(String sId)
Destroy the specified session. |
protected void |
destroyLocalAttributesCache(String sId)
Destroy the cache of local-only session attributes for the specified session ID. |
protected Map |
ensureLocalAttributesCache(String sId)
Get the cache of local-only session attributes for the specified session ID. |
boolean |
enter(String sId,
boolean fWait)
Obtain any necessary ownership for the specified session. |
void |
exit(String sId)
Release ownership for the specified session. |
void |
flush(String sId)
In a distributed environment, ensure that any changes to the specified session are flushed. |
protected String |
generateSessionId()
Generate a potential session ID. |
HttpSessionModel |
get(String sId)
Obtain the HttpSessionModel for the specified session, or null if it does not exist. |
int |
getAverageModelLifetime()
Calculate the average lifetime (in seconds) of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset. |
int |
getAverageModelSize()
Calculate the average size (in bytes) of session model objects placed in the session storage clustered cache since the last time statistics were reset. |
NamedCache |
getClusterCache()
Get the cache of existent distributed session models. |
protected static AbstractHttpSessionCollection |
getCollection()
Obtain the AbstractHttpSessionCollection that is being used in the current application. |
XmlElement |
getConfig()
Determine the current configuration of the object. |
protected long |
getCurrentTime()
Determine the current time value in milliseconds. |
NamedCache |
getDeathCertCache()
Get the cache of previously used session IDs (IDs of previously existent HttpSessionModel objects). |
int |
getDefaultMaxInactiveInterval()
Determine the default maximum interval, in seconds, that a session will be kept alive without any activity. |
protected String |
getDescription()
Returns a string representation of this object's attributes. |
protected HttpSessionCollection.SessionDistributionController |
getDistributionController()
Get the SessionDistributionController for the session collection, if one was specified. |
protected Listeners |
getHttpSessionAttributeListeners()
Determine the list of listeners that are registered for session attribute modification events. |
protected Listeners |
getHttpSessionListeners()
Determine the list of listeners that are registered for session life cycle events. |
NamedCache |
getLocalAttributesCache()
Get the cache of local-only session attributes. |
NamedCache |
getLocalCache()
Get the cache of existent local-only session models. |
int |
getMaxModelSize()
Return the maximum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset. |
int |
getMinModelSize()
Return the minimum size (in bytes) of a session model object placed in the session storage clustered cache since the last time statistics were reset. |
protected AbstractHttpSessionModel |
getModel(String sId)
Obtain the specified session model. |
int |
getModelDeaths()
Return the number of session model objects invalidated (either due to expiration or to an explicit invalidation) since the last time statistics were reset. |
int |
getModelUpdates()
Return the number of updates to session model objects since the last time statistics were reset. |
protected NamedCache |
getOwnedCache()
Get the cache of owned ("locally live") session models. |
protected AbstractHttpSessionModel |
getOwnedModel(String sId)
Obtain the specified session model that this thread owns, otherwise throw an exception. |
int |
getSessionIdLength()
Determine the length that session IDs will be created with. |
NamedCache |
getStickyCache()
Get the cache of sessions that are being managed by this member, if sticky ownership is used. |
protected InvocationService |
getStickyService()
Get the invocation service to use to manage sticky session ownership. |
protected abstract AbstractHttpSessionModel |
instantiateModel(HttpSession session,
String sId)
Factory Method: Instantiate a AbstractHttpSessionModel or subclass thereof. |
boolean |
isActive(String sId)
Determine if the specified session ID identifies a session that is in the active state. |
protected boolean |
isAllowLocalAttributes()
Determine if non-serializable attributes should be preserved as local. |
protected boolean |
isAssumeLocality()
Determine if it can be assumed that each existent session is managed on a server that is doing reaping, and thus each server can reap only the sessions that are managed on it. |
boolean |
isExistent(String sId)
Determine if the specified session ID identifies a session that exists. |
protected boolean |
isModelSingleThreaded()
Determine whether a session should be single threaded (only one request per session accessing the session at a time) or multithreaded (any number of requests accessing the session at a time on a specific server). |
boolean |
isOwned(String sId)
Determine if the specified session ID identifies a session that exists and that this thread has ownership for, either by a call to enter(sId) or create() without a corresponding
call to exit(sId) . |
boolean |
isOwnershipSticky()
Determine if the sticky session ownership option is on. |
boolean |
isStrict()
Determine if the Servlet specification is being followed strictly. |
protected boolean |
isStuck(String sId)
Determine if the specified session is stuck. |
Iterator |
iterateIds()
Obtain an iterator of the session IDs. |
Iterator |
iterateLocalIds()
Obtain an iterator of the session IDs that this JVM is responsible for invalidating when the sessions for those IDs have timed out. |
protected boolean |
obtainClusterOwnership(String sId,
boolean fWait)
Obtain ownership within the cluster for the specified session. |
protected void |
onModelUpdate(int cb)
Notify the session collection that a model of the specified size (in bytes) was updated in the session storage clustered cache. |
void |
passivate(String sId)
Move the session into a passive state, if it is not already. |
void |
postCreate(HttpSession session)
This method is called at the end of the session creation process. |
protected static void |
putBlind(Map map,
Object oKey,
Object oValue)
Puts the specified key/value pair into the specified map using the putAll() method, which does not return the previous value and thus may be more efficient in a distributed environment. |
void |
releaseCache(NamedCache cache)
Release the passed NamedCache instance. |
protected void |
releaseClusterOwnership(String sId)
Release ownership within the cluster of the specified session. |
protected boolean |
releaseStuckSession(String sId)
Determine if the specified session is stuck, and if it is, to release it (or mark it to be released). |
protected static void |
removeBlind(Map map,
Object oKey)
Removes the specified key/value pair from the specified map using the keySet().remove() method, which does not return the previous value and thus may be more efficient in a distributed environment. |
void |
removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
Sign off the specified listener so it no longer will receive HttpSessionBindingEvent objects. |
void |
removeHttpSessionListener(HttpSessionListener listener)
Sign off the specified listener so it no longer will receive HttpSessionEvent objects. |
void |
resetStatistics()
Reset all statistics maintained by this session collection. |
void |
setConfig(XmlElement xml)
Specify the configuration for the object. |
void |
shutdown()
Notify the session collection that it is being shut down. |
String |
toString()
Returns a string representation of the object. |
Field Detail |
---|
public static final String CTX_INIT_CACHENAME_SESSIONS
public static final String CTX_INIT_CACHENAME_LOCAL_SESSIONS
public static final String CTX_INIT_CACHENAME_LOCAL_ATTRIBUTES
public static final String CTX_INIT_CACHENAME_DEATHCERTS
public static final String CTX_INIT_SESSION_EXPIRE_SECS
public static final String CTX_INIT_SESSION_ID_LENGTH
public static final String CTX_INIT_SESSION_THREAD_LOCK
public static final String CTX_INIT_DAEMON_ASSUME_LOCALITY
public static final String CTX_INIT_SESSION_STRICT_SPEC
public static final String CTX_INIT_CONTROLLER_CLASS
public static final String CTX_INIT_SESSION_STICKY
public static final String CTX_INIT_SERVICENAME_OWNERSHIP
public static final String CTX_INIT_ALLOW_LOCAL_ATTRIBUTES
public static final String CACHENAME_SESSIONS
public static final String CACHENAME_LOCAL_SESSIONS
public static final String CACHENAME_LOCAL_ATTRIBUTES
public static final String CACHENAME_DEATHCERTS
public static final String SERVICENAME_OWNERSHIP
Constructor Detail |
---|
public AbstractHttpSessionCollection()
Method Detail |
---|
protected static AbstractHttpSessionCollection getCollection()
public XmlElement getConfig()
getConfig
in interface XmlConfigurable
public void setConfig(XmlElement xml)
setConfig
in interface XmlConfigurable
xml
- the XML configuration for the object
IllegalStateException
- if the object is not in a state that
allows the configuration to be set; for example, if the
object has already been configured and cannot be reconfiguredpublic HttpSessionModel create(HttpSession session)
The session is created with the default timeout, and has an ID that is unique within the domain that the session management layer is configured for (e.g. within the JVM, or within the cluster.)
When the session model is returned, the session state is exists,
owned, active. Note that the responsibilities associated with
the enter(sId)
method are included as part of the session
creation process.
The model will retain the reference to the HttpSession object until it is passivated or destroyed.
create
in interface HttpSessionCollection
session
- the HttpSession object to bind the session model to;
used for issuing events; must not be null
public void postCreate(HttpSession session)
When this method is called, the session state is exists, owned, active.
postCreate
in interface HttpSessionCollection
session
- the HttpSession object; must not be nullpublic boolean isExistent(String sId)
The notion of ownership will affect whether or not the answer can be
trusted once the method has returned it. If the ownership state is
owned (the current thread called enter(sId)
),
then the caller should assume that session still exists. Otherwise,
the caller can only assume that the session did exist at the
point in time that the call to this method was made.
isExistent
in interface HttpSessionCollection
sId
- the session ID to check for existence
public void destroy(String sId)
This method may only be called on a session that is exists, owned, active.
Session attributes will receive HttpSessionBindingListener as per the Servlet specification.
At the return point from this method, the session state is does
not exist. Note that the responsibilities associated with the
exit(sId)
method are included as part of the session
destruction process.
After this method completes, the model's HttpSession reference will be null.
destroy
in interface HttpSessionCollection
sId
- the session ID; must not be nullpublic boolean enter(String sId, boolean fWait)
If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
This method must support Multiple Possession Semantics, meaning
that this method may be invoked multiple times, and each invocation
will require a corresponding call to the exit(sId)
method
in order to release the ownership.
enter
in interface HttpSessionCollection
sId
- the session ID; must not be nullfWait
- true if the thread should block until the session becomes
available; false otherwise
public boolean isOwned(String sId)
enter(sId)
or create()
without a corresponding
call to exit(sId)
.
isOwned
in interface HttpSessionCollection
public void exit(String sId)
enter(sId)
, with the
only exceptions being:
enter(sId)
method was never invoked.When ownership state of a new session changes from owned to not owned, the session will no longer be considered new.
If the session specified by the session ID does not exist, then this method has no effect; no exception is thrown.
exit
in interface HttpSessionCollection
sId
- the session ID; must not be nullpublic void activate(String sId, HttpSession session)
Invoking this method will issue activation events for session attributes that implement the HttpSessionActivationListener interface. The model will retain the reference to the HttpSession object until it is passivated or destroyed.
activate
in interface HttpSessionCollection
sId
- the session ID; must not be nullsession
- the HttpSession object to bind the session model to;
used for issuing events; must not be nullpublic boolean isActive(String sId)
This method may only be called within the bounds of a call to
enter(sId)
and exit(sId)
.
isActive
in interface HttpSessionCollection
sId
- the session ID to check for the active state
public void passivate(String sId)
Invoking this method will issue passivation events for session attributes that implement the HttpSessionActivationListener interface.
After this method completes, the model's HttpSession reference will be null.
passivate
in interface HttpSessionCollection
sId
- the session ID; must not be nullpublic Iterator iterateIds()
The list of IDs is completely dynamic because of the nature of multi-threaded and distributed systems. The fact that an ID is returned from an iterator is no guarantee that the ID is still valid.
iterateIds
in interface HttpSessionCollection
public Iterator iterateLocalIds()
This may return an iterator with the same contents as the one
returned by the iterateIds()
method, or it may return
an iterator that iterates over a subset of those contents.
The list of IDs is completely dynamic because of the nature of multi-threaded and distributed systems. The fact that an ID is returned from an iterator is no guarantee that the ID is still valid.
iterateLocalIds
in interface HttpSessionCollection
public HttpSessionModel get(String sId)
This method may only be called within the bounds of a call to
enter(sId)
and exit(sId)
.
get
in interface HttpSessionCollection
sId
- the session ID; must not be null
public void flush(String sId)
This method may only be called within the bounds of a call to
enter(sId)
and exit(sId)
.
flush
in interface HttpSessionCollection
sId
- the session ID; must not be nullpublic void addHttpSessionListener(HttpSessionListener listener)
addHttpSessionListener
in interface HttpSessionCollection
listener
- the HttpSessionListener to sign up for eventspublic void removeHttpSessionListener(HttpSessionListener listener)
removeHttpSessionListener
in interface HttpSessionCollection
listener
- the HttpSessionListener that was previously signed up
for eventspublic void addHttpSessionAttributeListener(HttpSessionAttributeListener listener)
addHttpSessionAttributeListener
in interface HttpSessionCollection
listener
- the HttpSessionAttributeListener to sign up for eventspublic void removeHttpSessionAttributeListener(HttpSessionAttributeListener listener)
removeHttpSessionAttributeListener
in interface HttpSessionCollection
listener
- the HttpSessionAttributeListener that was previously
signed up for eventspublic void shutdown()
shutdown
in interface HttpSessionCollection
public String toString()
protected Listeners getHttpSessionListeners()
protected Listeners getHttpSessionAttributeListeners()
public boolean isStrict()
public int getDefaultMaxInactiveInterval()
protected boolean isModelSingleThreaded()
protected long getCurrentTime()
protected String getDescription()
public NamedCache getStickyCache()
protected InvocationService getStickyService()
protected NamedCache getOwnedCache()
public NamedCache getClusterCache()
protected HttpSessionCollection.SessionDistributionController getDistributionController()
public NamedCache getLocalCache()
public NamedCache getLocalAttributesCache()
protected Map ensureLocalAttributesCache(String sId)
sId
- the session ID
protected void destroyLocalAttributesCache(String sId)
sId
- the session IDpublic NamedCache getDeathCertCache()
public boolean isOwnershipSticky()
This is available only if an Enterprise Edition or Grid Edition license is available.
protected boolean isStuck(String sId)
sId
- the session id
protected boolean obtainClusterOwnership(String sId, boolean fWait)
This method assumes that the owned cache is locked for the passed session ID.
sId
- the ID of the session to obtain ownership forfWait
- true to wait for the session to become available,
false to give up immediately if ownership of the
session is currently unavailable
protected void releaseClusterOwnership(String sId)
This method assumes that the owned cache is locked for the passed session ID.
sId
- the ID of the session to release ownership ofprotected boolean releaseStuckSession(String sId)
sId
- the session id to unstick if it's stuck here
protected boolean isAllowLocalAttributes()
This feature is available only if the sticky session ownership option is on and is enforced if a distribution controller is specified.
protected boolean isAssumeLocality()
protected String generateSessionId()
public int getSessionIdLength()
protected abstract AbstractHttpSessionModel instantiateModel(HttpSession session, String sId)
session
- the session that delegates to this modelsId
- the session ID
protected AbstractHttpSessionModel getOwnedModel(String sId)
IllegalStateException
- if the model does not exist, or it is
not owned by this threadprotected AbstractHttpSessionModel getModel(String sId)
protected static void putBlind(Map map, Object oKey, Object oValue)
map
- the map to store the key/value pair intooKey
- the key to storeoValue
- the value to storeprotected static void removeBlind(Map map, Object oKey)
map
- the map to remove the key/value pair fromoKey
- the key to removepublic void releaseCache(NamedCache cache)
cache
- a NamedCache instance to release (may be null)public int getAverageModelLifetime()
public int getAverageModelSize()
public int getMaxModelSize()
public int getMinModelSize()
public int getModelDeaths()
public int getModelUpdates()
public void resetStatistics()
protected void onModelUpdate(int cb)
cb
- the size (in bytes) of the session model
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |