@ManagedObject(value="Abstract Session Manager") public abstract class AbstractSessionManager extends ContainerLifeCycle implements SessionManager
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractSessionManager.CookieConfig
CookieConfig
Implementation of the javax.servlet.SessionCookieConfig.
|
static interface |
AbstractSessionManager.SessionIf
Interface that any session wrapper should implement so that
SessionManager may access the Jetty session implementation.
|
AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.ListenerFAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty| Constructor and Description |
|---|
AbstractSessionManager() |
| Modifier and Type | Method and Description |
|---|---|
HttpCookie |
access(HttpSession session,
boolean secure)
Called by the
SessionHandler when a session is first accessed by a request. |
void |
addEventListener(EventListener listener)
Adds an event listener for session-related events.
|
protected abstract void |
addSession(AbstractSession session) |
protected void |
addSession(AbstractSession session,
boolean created)
Add the session Registers the session with this manager and registers the
session ID with the sessionIDManager;
|
void |
clearEventListeners()
Removes all event listeners for session-related events.
|
void |
complete(HttpSession session)
Called by the
SessionHandler when a session is last accessed by a request. |
void |
doSessionAttributeListeners(AbstractSession session,
String name,
Object old,
Object value) |
void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
String |
getClusterId(HttpSession session) |
ContextHandler.Context |
getContext() |
ContextHandler |
getContextHandler() |
Set<SessionTrackingMode> |
getDefaultSessionTrackingModes() |
Set<SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
boolean |
getHttpOnly() |
HttpSession |
getHttpSession(String nodeId)
Returns the
HttpSession with the given session id |
int |
getMaxCookieAge() |
int |
getMaxInactiveInterval() |
SessionIdManager |
getMetaManager()
Deprecated.
|
String |
getNodeId(HttpSession session) |
int |
getRefreshCookieAge() |
boolean |
getSecureCookies() |
abstract AbstractSession |
getSession(String idInCluster)
Get a known existing session
|
String |
getSessionCookie() |
HttpCookie |
getSessionCookie(HttpSession session,
String contextPath,
boolean requestIsSecure)
A sessioncookie is marked as secure IFF any of the following conditions are true:
SessionCookieConfig.setSecure == true
SessionCookieConfig.setSecure == false && _secureRequestOnly==true && request is HTTPS
According to SessionCookieConfig javadoc, case 1 can be used when:
"...
|
SessionCookieConfig |
getSessionCookieConfig() |
String |
getSessionDomain() |
SessionHandler |
getSessionHandler() |
SessionIdManager |
getSessionIdManager() |
String |
getSessionIdPathParameterName() |
String |
getSessionIdPathParameterNamePrefix() |
String |
getSessionPath() |
int |
getSessions() |
int |
getSessionsMax() |
int |
getSessionsTotal() |
long |
getSessionTimeMax() |
double |
getSessionTimeMean() |
double |
getSessionTimeStdDev() |
long |
getSessionTimeTotal() |
boolean |
isCheckingRemoteSessionIdEncoding() |
boolean |
isNodeIdInSessionId() |
boolean |
isSecureRequestOnly() |
boolean |
isUsingCookies() |
boolean |
isUsingURLs() |
boolean |
isValid(HttpSession session) |
HttpSession |
newHttpSession(HttpServletRequest request)
Create a new HttpSession for a request
|
protected abstract AbstractSession |
newSession(HttpServletRequest request)
Create a new session instance
|
void |
removeEventListener(EventListener listener)
Removes an event listener for for session-related events.
|
boolean |
removeSession(AbstractSession session,
boolean invalidate)
Remove session from manager
|
void |
removeSession(HttpSession session,
boolean invalidate)
Remove session from manager
|
protected abstract boolean |
removeSession(String idInCluster) |
void |
renewSessionId(String oldClusterId,
String oldNodeId,
String newClusterId,
String newNodeId)
Tell the HttpSessionIdListeners the id changed.
|
void |
setCheckingRemoteSessionIdEncoding(boolean remote) |
void |
setHttpOnly(boolean httpOnly) |
void |
setMaxInactiveInterval(int seconds)
Sets the max period of inactivity, after which the session is invalidated, in seconds.
|
void |
setNodeIdInSessionId(boolean nodeIdInSessionId) |
void |
setRefreshCookieAge(int ageInSeconds) |
void |
setSecureRequestOnly(boolean secureRequestOnly)
HTTPS request.
|
void |
setSessionCookie(String cookieName) |
void |
setSessionHandler(SessionHandler sessionHandler)
Sets the
SessionHandler. |
void |
setSessionIdManager(SessionIdManager metaManager)
Sets the cross context session id manager
|
void |
setSessionIdPathParameterName(String param)
Sets the session id URL path parameter name.
|
void |
setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) |
void |
setUsingCookies(boolean usingCookies) |
protected abstract void |
shutdownSessions()
Prepare sessions for session manager shutdown
|
void |
statsReset()
Reset statistics values
|
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stoppublic Set<SessionTrackingMode> __defaultSessionTrackingModes
public static final int __distantFuture
protected int _dftMaxIdleSecs
protected SessionHandler _sessionHandler
protected boolean _httpOnly
protected SessionIdManager _sessionIdManager
protected boolean _secureCookies
protected boolean _secureRequestOnly
protected final List<HttpSessionAttributeListener> _sessionAttributeListeners
protected final List<HttpSessionListener> _sessionListeners
protected final List<HttpSessionIdListener> _sessionIdListeners
protected ClassLoader _loader
protected ContextHandler.Context _context
protected String _sessionCookie
protected String _sessionIdPathParameterName
protected String _sessionIdPathParameterNamePrefix
protected String _sessionDomain
protected String _sessionPath
protected int _maxCookieAge
protected int _refreshCookieAge
protected boolean _nodeIdInSessionId
protected boolean _checkingRemoteSessionIdEncoding
protected String _sessionComment
public Set<SessionTrackingMode> _sessionTrackingModes
protected final CounterStatistic _sessionsStats
protected final SampleStatistic _sessionTimeStats
public ContextHandler.Context getContext()
public ContextHandler getContextHandler()
@ManagedAttribute(value="path of the session cookie, or null for default") public String getSessionPath()
@ManagedAttribute(value="if greater the zero, the time in seconds a session cookie will last for") public int getMaxCookieAge()
public HttpCookie access(HttpSession session, boolean secure)
SessionManagerSessionHandler when a session is first accessed by a request.access in interface SessionManagersession - the session objectsecure - whether the request is secure or notSessionManager.complete(HttpSession)public void addEventListener(EventListener listener)
SessionManageraddEventListener in interface SessionManagerlistener - the session event listener to add
Individual SessionManagers implementations may accept arbitrary listener types,
but they are expected to at least handle HttpSessionActivationListener,
HttpSessionAttributeListener, HttpSessionBindingListener and HttpSessionListener.SessionManager.removeEventListener(EventListener)public void clearEventListeners()
SessionManagerclearEventListeners in interface SessionManagerSessionManager.removeEventListener(EventListener)public void complete(HttpSession session)
SessionManagerSessionHandler when a session is last accessed by a request.complete in interface SessionManagersession - the session objectSessionManager.access(HttpSession, boolean)public void doStart()
throws Exception
ContainerLifeCycledoStart in class ContainerLifeCycleExceptionpublic void doStop()
throws Exception
ContainerLifeCycledoStop in class ContainerLifeCycleException@ManagedAttribute(value="true if cookies use the http only flag") public boolean getHttpOnly()
getHttpOnly in interface SessionManagerHttpCookie.isHttpOnly()public HttpSession getHttpSession(String nodeId)
SessionManagerHttpSession with the given session idgetHttpSession in interface SessionManagernodeId - the session idHttpSession with the corresponding id or null if no session with the given id exists@ManagedAttribute(value="Session ID Manager") public SessionIdManager getSessionIdManager()
getSessionIdManager in interface SessionManagerSessionManager.setSessionIdManager(SessionIdManager)@ManagedAttribute(value="defailt maximum time a session may be idle for (in s)") public int getMaxInactiveInterval()
getMaxInactiveInterval in interface SessionManagerSessionManager.setMaxInactiveInterval(int)@ManagedAttribute(value="maximum number of simultaneous sessions") public int getSessionsMax()
@ManagedAttribute(value="total number of sessions") public int getSessionsTotal()
@ManagedAttribute(value="time before a session cookie is re-set (in s)") public int getRefreshCookieAge()
@ManagedAttribute(value="if true, secure cookie flag is set on session cookies") public boolean getSecureCookies()
public boolean isSecureRequestOnly()
public void setSecureRequestOnly(boolean secureRequestOnly)
@ManagedAttribute(value="the set session cookie") public String getSessionCookie()
public HttpCookie getSessionCookie(HttpSession session, String contextPath, boolean requestIsSecure)
getSessionCookie in interface SessionManagersession - the session to which the cookie should refer.contextPath - the context to which the cookie should be linked.
The client will only send the cookie value when requesting resources under this path.requestIsSecure - whether the client is accessing the server over a secure protocol (i.e. HTTPS).SessionManager uses cookies, then this method will return a new
cookie object that should be set on the client in order to link future HTTP requests
with the session. If cookies are not in use, this method returns null.SessionManager.getSessionCookie(javax.servlet.http.HttpSession, java.lang.String, boolean)@ManagedAttribute(value="domain of the session cookie, or null for the default") public String getSessionDomain()
public SessionHandler getSessionHandler()
@ManagedAttribute(value="number of currently active sessions") public int getSessions()
@ManagedAttribute(value="name of use for URL session tracking") public String getSessionIdPathParameterName()
getSessionIdPathParameterName in interface SessionManagerSessionManager.setSessionIdPathParameterName(String)public String getSessionIdPathParameterNamePrefix()
getSessionIdPathParameterNamePrefix in interface SessionManagerSessionManager.getSessionIdPathParameterName(), by default
";" + sessionIdParameterName + "=", for easier lookup in URL strings.SessionManager.getSessionIdPathParameterName()public boolean isUsingCookies()
isUsingCookies in interface SessionManagerpublic boolean isValid(HttpSession session)
isValid in interface SessionManagersession - the session to test for validitypublic String getClusterId(HttpSession session)
getClusterId in interface SessionManagersession - the session objectSessionManager.getNodeId(HttpSession)public String getNodeId(HttpSession session)
getNodeId in interface SessionManagersession - the session objectSessionManager.getClusterId(HttpSession)public HttpSession newHttpSession(HttpServletRequest request)
newHttpSession in interface SessionManagerrequest - the HttpServletRequest containing the requested session idHttpSessionpublic void removeEventListener(EventListener listener)
SessionManagerremoveEventListener in interface SessionManagerlistener - the session event listener to removeSessionManager.addEventListener(EventListener)@ManagedOperation(value="reset statistics", impact="ACTION") public void statsReset()
public void setHttpOnly(boolean httpOnly)
httpOnly - The httpOnly to set.public void setSessionIdManager(SessionIdManager metaManager)
SessionManagersetSessionIdManager in interface SessionManagermetaManager - The metaManager used for cross context session management.SessionManager.getSessionIdManager()public void setMaxInactiveInterval(int seconds)
SessionManagersetMaxInactiveInterval in interface SessionManagerseconds - SessionManager.getMaxInactiveInterval()public void setRefreshCookieAge(int ageInSeconds)
public void setSessionCookie(String cookieName)
public void setSessionHandler(SessionHandler sessionHandler)
SessionManagerSessionHandler.setSessionHandler in interface SessionManagersessionHandler - The sessionHandler to set.public void setSessionIdPathParameterName(String param)
SessionManagersetSessionIdPathParameterName in interface SessionManagerparam - the URL path parameter name for session id URL rewriting (null or "none" for no rewriting).SessionManager.getSessionIdPathParameterName(),
SessionManager.getSessionIdPathParameterNamePrefix()public void setUsingCookies(boolean usingCookies)
usingCookies - The usingCookies to set.protected abstract void addSession(AbstractSession session)
protected void addSession(AbstractSession session, boolean created)
public abstract AbstractSession getSession(String idInCluster)
idInCluster - The session ID in the cluster, stripped of any worker name.protected abstract void shutdownSessions()
throws Exception
Exceptionprotected abstract AbstractSession newSession(HttpServletRequest request)
request - public boolean isNodeIdInSessionId()
HttpSession.getId(). Default is false.public void setNodeIdInSessionId(boolean nodeIdInSessionId)
nodeIdInSessionId - true if the cluster node id (worker id) will be returned as part of the session id by HttpSession.getId(). Default is false.public void removeSession(HttpSession session, boolean invalidate)
session - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.public boolean removeSession(AbstractSession session, boolean invalidate)
session - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.protected abstract boolean removeSession(String idInCluster)
@ManagedAttribute(value="maximum amount of time sessions have remained active (in s)") public long getSessionTimeMax()
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes in interface SessionManagerpublic Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes in interface SessionManagerpublic void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes in interface SessionManagerpublic boolean isUsingURLs()
isUsingURLs in interface SessionManagerpublic SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig in interface SessionManager@ManagedAttribute(value="total time sessions have remained valid") public long getSessionTimeTotal()
@ManagedAttribute(value="mean time sessions remain valid (in s)") public double getSessionTimeMean()
@ManagedAttribute(value="standard deviation a session remained valid (in s)") public double getSessionTimeStdDev()
@ManagedAttribute(value="check remote session id encoding") public boolean isCheckingRemoteSessionIdEncoding()
isCheckingRemoteSessionIdEncoding in interface SessionManagerSessionManager.isCheckingRemoteSessionIdEncoding()public void setCheckingRemoteSessionIdEncoding(boolean remote)
setCheckingRemoteSessionIdEncoding in interface SessionManagerremote - True if absolute URLs are check for remoteness before being session encoded.SessionManager.setCheckingRemoteSessionIdEncoding(boolean)public void renewSessionId(String oldClusterId, String oldNodeId, String newClusterId, String newNodeId)
renewSessionId in interface SessionManagerSessionManager.renewSessionId(java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void doSessionAttributeListeners(AbstractSession session, String name, Object old, Object value)
@Deprecated public SessionIdManager getMetaManager()
getMetaManager in interface SessionManagerCopyright © 1995-2015 Webtide. All Rights Reserved.