public abstract class AbstractSessionManager extends AbstractLifeCycle implements SessionManager
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractSessionManager.SessionIf
Interface that any session wrapper should implement so that
SessionManager may access the Jetty session implementation.
|
AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.Listener_listeners, FAILED, 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(javax.servlet.http.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(javax.servlet.http.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() |
void |
doStop() |
String |
getClusterId(javax.servlet.http.HttpSession session) |
ContextHandler.Context |
getContext() |
ContextHandler |
getContextHandler() |
Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes() |
Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
boolean |
getHttpOnly() |
javax.servlet.http.HttpSession |
getHttpSession(String nodeId)
Returns the
HttpSession with the given session id |
SessionIdManager |
getIdManager()
Deprecated.
|
int |
getMaxCookieAge() |
int |
getMaxInactiveInterval() |
int |
getMaxSessions()
Deprecated.
|
SessionIdManager |
getMetaManager()
Deprecated.
|
int |
getMinSessions()
Deprecated.
always returns 0. no replacement available.
|
String |
getNodeId(javax.servlet.http.HttpSession session) |
int |
getRefreshCookieAge() |
boolean |
getSecureCookies() |
abstract AbstractSession |
getSession(String idInCluster)
Get a known existing session
|
String |
getSessionCookie() |
HttpCookie |
getSessionCookie(javax.servlet.http.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:
"...
|
javax.servlet.SessionCookieConfig |
getSessionCookieConfig() |
String |
getSessionDomain() |
SessionHandler |
getSessionHandler() |
SessionIdManager |
getSessionIdManager() |
String |
getSessionIdPathParameterName() |
String |
getSessionIdPathParameterNamePrefix() |
Map |
getSessionMap()
Deprecated.
Need to review if it is needed.
|
String |
getSessionPath() |
int |
getSessions() |
int |
getSessionsMax() |
int |
getSessionsTotal() |
long |
getSessionTimeMax() |
double |
getSessionTimeMean() |
double |
getSessionTimeStdDev() |
long |
getSessionTimeTotal() |
protected abstract void |
invalidateSessions() |
boolean |
isCheckingRemoteSessionIdEncoding() |
boolean |
isNodeIdInSessionId() |
boolean |
isSecureRequestOnly() |
boolean |
isUsingCookies() |
boolean |
isUsingURLs() |
boolean |
isValid(javax.servlet.http.HttpSession session) |
javax.servlet.http.HttpSession |
newHttpSession(javax.servlet.http.HttpServletRequest request)
Create a new HttpSession for a request
|
protected abstract AbstractSession |
newSession(javax.servlet.http.HttpServletRequest request)
Create a new session instance
|
void |
removeEventListener(EventListener listener)
Removes an event listener for for session-related events.
|
void |
removeSession(AbstractSession session,
boolean invalidate)
Remove session from manager
|
void |
removeSession(javax.servlet.http.HttpSession session,
boolean invalidate)
Remove session from manager
|
protected abstract boolean |
removeSession(String idInCluster) |
static javax.servlet.http.HttpSession |
renewSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession httpSession,
boolean authenticated) |
void |
resetStats()
Deprecated.
|
void |
setCheckingRemoteSessionIdEncoding(boolean remote) |
void |
setHttpOnly(boolean httpOnly) |
void |
setIdManager(SessionIdManager metaManager)
Deprecated.
|
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) |
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<javax.servlet.SessionTrackingMode> sessionTrackingModes) |
void |
setUsingCookies(boolean usingCookies) |
void |
statsReset()
Reset statistics values
|
addLifeCycleListener, getState, getState, 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<javax.servlet.SessionTrackingMode> __defaultSessionTrackingModes
public static final String SESSION_KNOWN_ONLY_TO_AUTHENTICATED
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<javax.servlet.http.HttpSessionAttributeListener> _sessionAttributeListeners
protected final List<javax.servlet.http.HttpSessionListener> _sessionListeners
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<javax.servlet.SessionTrackingMode> _sessionTrackingModes
protected final CounterStatistic _sessionsStats
protected final SampleStatistic _sessionTimeStats
public static javax.servlet.http.HttpSession renewSession(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession httpSession,
boolean authenticated)
public ContextHandler.Context getContext()
public ContextHandler getContextHandler()
public String getSessionPath()
public int getMaxCookieAge()
public HttpCookie access(javax.servlet.http.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(javax.servlet.http.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
doStart in class AbstractLifeCycleExceptionpublic void doStop()
throws Exception
doStop in class AbstractLifeCycleExceptionpublic boolean getHttpOnly()
getHttpOnly in interface SessionManagerHttpCookie.isHttpOnly()public javax.servlet.http.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 existspublic SessionIdManager getIdManager()
getSessionIdManager()public SessionIdManager getSessionIdManager()
getSessionIdManager in interface SessionManagerSessionManager.setSessionIdManager(SessionIdManager)public int getMaxInactiveInterval()
getMaxInactiveInterval in interface SessionManagerSessionManager.setMaxInactiveInterval(int)@Deprecated public int getMaxSessions()
getSessionsMax()public int getSessionsMax()
public int getSessionsTotal()
@Deprecated public SessionIdManager getMetaManager()
getSessionIdManager()getMetaManager in interface SessionManager@Deprecated public int getMinSessions()
public int getRefreshCookieAge()
public boolean getSecureCookies()
public boolean isSecureRequestOnly()
public void setSecureRequestOnly(boolean secureRequestOnly)
public String getSessionCookie()
public HttpCookie getSessionCookie(javax.servlet.http.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)public String getSessionDomain()
public SessionHandler getSessionHandler()
public Map getSessionMap()
public int getSessions()
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(javax.servlet.http.HttpSession session)
isValid in interface SessionManagersession - the session to test for validitypublic String getClusterId(javax.servlet.http.HttpSession session)
getClusterId in interface SessionManagersession - the session objectSessionManager.getNodeId(HttpSession)public String getNodeId(javax.servlet.http.HttpSession session)
getNodeId in interface SessionManagersession - the session objectSessionManager.getClusterId(HttpSession)public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.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)@Deprecated public void resetStats()
statsReset()public void statsReset()
public void setHttpOnly(boolean httpOnly)
httpOnly - The httpOnly to set.public void setIdManager(SessionIdManager metaManager)
setSessionIdManager(SessionIdManager)metaManager - The metaManager used for cross context session management.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 AbstractSession newSession(javax.servlet.http.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(javax.servlet.http.HttpSession session,
boolean invalidate)
session - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.public void 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)
public long getSessionTimeMax()
public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes in interface SessionManagerpublic Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes in interface SessionManagerpublic void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes in interface SessionManagerpublic boolean isUsingURLs()
isUsingURLs in interface SessionManagerpublic javax.servlet.SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig in interface SessionManagerpublic long getSessionTimeTotal()
public double getSessionTimeMean()
public double getSessionTimeStdDev()
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 doSessionAttributeListeners(AbstractSession session, String name, Object old, Object value)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.