public abstract class ClusteredSession<O extends OutgoingDistributableSessionData> extends Object implements javax.servlet.http.HttpSession, org.apache.catalina.Session
Modifier and Type | Field and Description |
---|---|
protected static boolean |
ACTIVITY_CHECK |
protected static Class<?>[] |
containerEventTypes
The method signature for the
fireContainerEvent method. |
protected static String[] |
excludedAttributes
Set of attribute names which are not allowed to be replicated/persisted.
|
protected static String |
info
Descriptive information describing this Session implementation.
|
protected static org.jboss.logging.Logger |
log |
protected static Set<String> |
replicationExcludes
Set containing all members of
excludedAttributes . |
protected static javax.servlet.http.HttpSessionContext |
sessionContext
The dummy HTTP session context used for servlet spec compliance.
|
protected static org.apache.catalina.util.StringManager |
sm
The string manager for this package.
|
Modifier | Constructor and Description |
---|---|
protected |
ClusteredSession(ClusteredSessionManager<O> manager)
Creates a new ClusteredSession.
|
Modifier and Type | Method and Description |
---|---|
void |
access() |
void |
addSessionListener(org.apache.catalina.SessionListener listener) |
protected boolean |
canAttributeBeReplicated(Object attribute)
Returns whether the attribute's type is one that can be replicated.
|
void |
endAccess() |
protected void |
establishDistributedCacheManager()
Gets a reference to the JBossCacheService.
|
void |
expire() |
void |
expire(boolean notify,
boolean localCall,
boolean localOnly,
ClusteredSessionNotificationCause cause)
Expires the session, notifying listeners and possibly the manager.
|
Object |
getAttribute(String name) |
protected Object |
getAttributeInternal(String name) |
Enumeration<String> |
getAttributeNames() |
protected Map<String,Object> |
getAttributesInternal() |
String |
getAuthType() |
long |
getCreationTime() |
long |
getCreationTimeInternal()
Gets the sessions creation time, skipping any validity check.
|
protected DistributedCacheManager<O> |
getDistributedCacheManager() |
String |
getId() |
String |
getIdInternal() |
long |
getLastAccessedTime() |
long |
getLastAccessedTimeInternal() |
long |
getLastReplicated()
Gets the time
processSessionReplication() was last called, or 0 if it has never been called. |
org.apache.catalina.Manager |
getManager() |
protected ClusteredSessionManager<O> |
getManagerInternal() |
int |
getMaxInactiveInterval() |
long |
getMaxUnreplicatedInterval()
Gets the maximum period in ms after which a request accessing this session will trigger replication of its timestamp,
even if the request doesn't otherwise modify the session.
|
boolean |
getMustReplicateTimestamp() |
boolean |
getNeedsPostReplicateActivation()
Gets whether the session needs to notify HttpSessionActivationListeners that it has been activated following replication.
|
Object |
getNote(String name) |
Iterator<String> |
getNoteNames() |
protected abstract O |
getOutgoingSessionData() |
Principal |
getPrincipal() |
String |
getRealId()
Gets the session id with any appended jvmRoute info removed.
|
javax.servlet.ServletContext |
getServletContext() |
javax.servlet.http.HttpSession |
getSession() |
javax.servlet.http.HttpSessionContext |
getSessionContext()
Deprecated.
|
protected DistributableSessionMetadata |
getSessionMetadata() |
protected long |
getSessionTimestamp() |
Object |
getValue(String name)
Deprecated.
|
String[] |
getValueNames()
Deprecated.
|
protected int |
getVersion() |
void |
invalidate()
Invalidates this session and unbinds any objects bound to it.
|
protected boolean |
isFullReplicationNeeded() |
protected boolean |
isGetDirty(Object attribute) |
protected boolean |
isMutable(Object attribute) |
boolean |
isNew() |
boolean |
isOutdated()
Check to see if the session data is still valid.
|
protected boolean |
isSessionAttributeMapDirty() |
boolean |
isSessionDirty() |
protected boolean |
isSessionMetadataDirty() |
boolean |
isValid()
Overrides the
superclass method to call @ #isValid(boolean) isValid(true)} . |
boolean |
isValid(boolean expireIfInvalid)
Returns whether the current session is still valid, but only calls
expire for timed-out sessions if
expireIfInvalid is true . |
boolean |
isValidInternal()
Return the
isValid flag for this session without any expiration check. |
void |
notifyDidActivate(ClusteredSessionNotificationCause cause)
Inform any HttpSessionActivationListener that the session has been activated.
|
void |
notifyWillPassivate(ClusteredSessionNotificationCause cause)
Inform any HttpSessionActivationListener that the session will passivate.
|
protected void |
populateAttributes(Map<String,Object> distributedCacheAttributes)
Extension point for subclasses to load the attribute map from the distributed cache.
|
void |
processSessionReplication()
Increment our version and propagate ourself to the distributed cache.
|
void |
putValue(String name,
Object value)
Deprecated.
|
void |
recycle() |
void |
removeAttribute(String name) |
protected abstract Object |
removeAttributeInternal(String name,
boolean localCall,
boolean localOnly) |
protected Map<String,Object> |
removeExcludedAttributes(Map<String,Object> attributes)
Removes any attribute whose name is found in
excludedAttributes from attributes and returns a Map
of all such attributes. |
void |
removeMyself()
Remove myself from the distributed cache.
|
void |
removeMyselfLocal()
Remove myself from the
|
void |
removeNote(String name) |
void |
removeSessionListener(org.apache.catalina.SessionListener listener) |
void |
removeValue(String name)
Deprecated.
|
void |
resetIdWithRouteInfo(String id)
This is called specifically for failover case using mod_jk where the new session has this node name in there.
|
protected void |
sessionAttributesDirty() |
void |
setAttribute(String name,
Object value) |
protected abstract Object |
setAttributeInternal(String name,
Object value) |
void |
setAuthType(String authType) |
void |
setCreationTime(long time)
Set the creation time for this session.
|
protected void |
setDistributedCacheManager(DistributedCacheManager<O> distributedCacheManager) |
protected void |
setHasActivationListener(boolean hasListener) |
void |
setId(String id)
Overrides the superclass method to also set the
realId property. |
void |
setManager(org.apache.catalina.Manager manager) |
void |
setMaxInactiveInterval(int interval)
Overrides the superclass to calculate
maxUnreplicatedInterval . |
void |
setMaxUnreplicatedInterval(long interval)
Sets the maximum period in ms after which a request accessing this session will trigger replication of its timestamp,
even if the request doesn't otherwise modify the session.
|
void |
setNew(boolean isNew) |
void |
setNote(String name,
Object value) |
void |
setPrincipal(Principal principal)
Set the authenticated Principal that is associated with this Session.
|
void |
setValid(boolean isValid) |
boolean |
setVersionFromDistributedCache(int version)
Update our version due to changes in the distributed cache.
|
void |
tellNew(ClusteredSessionNotificationCause cause)
Inform any HttpSessionListener of the creation of this session
|
String |
toString() |
void |
update(IncomingDistributableSessionData sessionData) |
protected static final boolean ACTIVITY_CHECK
protected static final String info
protected static final String[] excludedAttributes
protected static final Set<String> replicationExcludes
excludedAttributes
.protected static final Class<?>[] containerEventTypes
fireContainerEvent
method.protected static final org.jboss.logging.Logger log
protected static javax.servlet.http.HttpSessionContext sessionContext
protected static final org.apache.catalina.util.StringManager sm
protected ClusteredSession(ClusteredSessionManager<O> manager)
manager
- the manager for this sessionpublic String getAuthType()
getAuthType
in interface org.apache.catalina.Session
public void setAuthType(String authType)
setAuthType
in interface org.apache.catalina.Session
public long getCreationTime()
getCreationTime
in interface javax.servlet.http.HttpSession
getCreationTime
in interface org.apache.catalina.Session
public void setCreationTime(long time)
setCreationTime
in interface org.apache.catalina.Session
time
- The new creation timepublic String getId()
getId
in interface javax.servlet.http.HttpSession
getId
in interface org.apache.catalina.Session
public String getIdInternal()
getIdInternal
in interface org.apache.catalina.Session
public void setId(String id)
realId
property.setId
in interface org.apache.catalina.Session
public long getLastAccessedTime()
getLastAccessedTime
in interface javax.servlet.http.HttpSession
getLastAccessedTime
in interface org.apache.catalina.Session
public long getLastAccessedTimeInternal()
getLastAccessedTimeInternal
in interface org.apache.catalina.Session
public org.apache.catalina.Manager getManager()
getManager
in interface org.apache.catalina.Session
public void setManager(org.apache.catalina.Manager manager)
setManager
in interface org.apache.catalina.Session
public int getMaxInactiveInterval()
getMaxInactiveInterval
in interface javax.servlet.http.HttpSession
getMaxInactiveInterval
in interface org.apache.catalina.Session
public void setMaxInactiveInterval(int interval)
maxUnreplicatedInterval
.setMaxInactiveInterval
in interface javax.servlet.http.HttpSession
setMaxInactiveInterval
in interface org.apache.catalina.Session
public Principal getPrincipal()
getPrincipal
in interface org.apache.catalina.Session
public void setPrincipal(Principal principal)
Authenticator
with a
means to cache a previously authenticated Principal, and avoid potentially expensive Realm.authenticate()
calls on every request.setPrincipal
in interface org.apache.catalina.Session
principal
- The new Principal, or null
if nonepublic void access()
access
in interface org.apache.catalina.Session
public void endAccess()
endAccess
in interface org.apache.catalina.Session
public boolean isNew()
isNew
in interface javax.servlet.http.HttpSession
public void setNew(boolean isNew)
setNew
in interface org.apache.catalina.Session
public boolean isValid()
superclass method
to call @ #isValid(boolean) isValid(true)} .isValid
in interface org.apache.catalina.Session
public void setValid(boolean isValid)
setValid
in interface org.apache.catalina.Session
public void invalidate()
invalidate
in interface javax.servlet.http.HttpSession
IllegalStateException
- if this method is called on an invalidated sessionpublic void expire()
expire
in interface org.apache.catalina.Session
public void recycle()
recycle
in interface org.apache.catalina.Session
public void addSessionListener(org.apache.catalina.SessionListener listener)
addSessionListener
in interface org.apache.catalina.Session
public void removeSessionListener(org.apache.catalina.SessionListener listener)
removeSessionListener
in interface org.apache.catalina.Session
public Object getNote(String name)
getNote
in interface org.apache.catalina.Session
public Iterator<String> getNoteNames()
getNoteNames
in interface org.apache.catalina.Session
public void setNote(String name, Object value)
setNote
in interface org.apache.catalina.Session
public void removeNote(String name)
removeNote
in interface org.apache.catalina.Session
public javax.servlet.http.HttpSession getSession()
getSession
in interface org.apache.catalina.Session
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.http.HttpSession
public Object getAttribute(String name)
getAttribute
in interface javax.servlet.http.HttpSession
public Enumeration<String> getAttributeNames()
getAttributeNames
in interface javax.servlet.http.HttpSession
public void setAttribute(String name, Object value)
setAttribute
in interface javax.servlet.http.HttpSession
public void removeAttribute(String name)
removeAttribute
in interface javax.servlet.http.HttpSession
@Deprecated public javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext
in interface javax.servlet.http.HttpSession
@Deprecated public Object getValue(String name)
getValue
in interface javax.servlet.http.HttpSession
@Deprecated public String[] getValueNames()
getValueNames
in interface javax.servlet.http.HttpSession
@Deprecated public void putValue(String name, Object value)
putValue
in interface javax.servlet.http.HttpSession
@Deprecated public void removeValue(String name)
removeValue
in interface javax.servlet.http.HttpSession
public String getRealId()
#getUseJK()
public boolean getMustReplicateTimestamp()
public void update(IncomingDistributableSessionData sessionData)
public void processSessionReplication()
public void removeMyself()
public void removeMyselfLocal()
public long getCreationTimeInternal()
public long getLastReplicated()
processSessionReplication()
was last called, or 0
if it has never been called.public long getMaxUnreplicatedInterval()
public void setMaxUnreplicatedInterval(long interval)
public void resetIdWithRouteInfo(String id)
id
- public boolean setVersionFromDistributedCache(int version)
version
- the distributed cache versiontrue
public boolean isOutdated()
public boolean isSessionDirty()
public void tellNew(ClusteredSessionNotificationCause cause)
public boolean isValid(boolean expireIfInvalid)
expire
for timed-out sessions if
expireIfInvalid
is true
.expireIfInvalid
- true
if sessions that have been timed out should be expiredpublic void expire(boolean notify, boolean localCall, boolean localOnly, ClusteredSessionNotificationCause cause)
NOTE: The manager will only be notified of the expiration if localCall
is true
; otherwise it is the responsibility of the caller to notify the manager that the session is expired. (In the case of
JBossCacheManager, it is the manager itself that makes such a call, so it of course is aware).
notify
- whether servlet spec listeners should be notifiedlocalCall
- true
if this call originated due to local activity (such as a session invalidation in user
code or an expiration by the local background processing thread); false
if the expiration originated
due to some kind of event notification from the cluster.localOnly
- true
if the expiration should not be announced to the cluster, false
if other
cluster nodes should be made aware of the expiration. Only meaningful if localCall
is
true
.cause
- the cause of the expirationpublic void notifyWillPassivate(ClusteredSessionNotificationCause cause)
cause
- cause of the notification (e.g. ClusteredSessionNotificationCause.REPLICATION
or
ClusteredSessionNotificationCause.PASSIVATION
public void notifyDidActivate(ClusteredSessionNotificationCause cause)
cause
- cause of the notification (e.g. ClusteredSessionNotificationCause.REPLICATION
or
ClusteredSessionNotificationCause.PASSIVATION
public boolean getNeedsPostReplicateActivation()
protected abstract Object removeAttributeInternal(String name, boolean localCall, boolean localOnly)
protected abstract O getOutgoingSessionData()
protected void populateAttributes(Map<String,Object> distributedCacheAttributes)
protected final ClusteredSessionManager<O> getManagerInternal()
protected final DistributedCacheManager<O> getDistributedCacheManager()
protected final void setDistributedCacheManager(DistributedCacheManager<O> distributedCacheManager)
protected boolean canAttributeBeReplicated(Object attribute)
attribute
- the attributetrue
if attribute
is null
, Serializable
or an array of
primitives.protected final Map<String,Object> removeExcludedAttributes(Map<String,Object> attributes)
excludedAttributes
from attributes
and returns a Map
of all such attributes.attributes
- source map from which excluded attributes are to be removed.attributes
, or null
if no attributes were
removed.protected final boolean isGetDirty(Object attribute)
protected boolean isMutable(Object attribute)
protected void establishDistributedCacheManager()
protected final void sessionAttributesDirty()
protected final void setHasActivationListener(boolean hasListener)
protected int getVersion()
protected long getSessionTimestamp()
protected boolean isSessionMetadataDirty()
protected DistributableSessionMetadata getSessionMetadata()
protected boolean isSessionAttributeMapDirty()
protected boolean isFullReplicationNeeded()
public boolean isValidInternal()
isValid
flag for this session without any expiration check.isValidInternal
in interface org.apache.catalina.Session
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All rights reserved.