public class JDBCSessionManager extends AbstractSessionManager
SessionManager that persists sessions to a database to enable clustering.
Session data is persisted to the JettySessions table:
| Modifier and Type | Class and Description |
|---|---|
class |
JDBCSessionManager.Session
Session
Session instance.
|
AbstractSessionManager.CookieConfig, AbstractSessionManager.SessionIfAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener| Modifier and Type | Field and Description |
|---|---|
protected JDBCSessionIdManager |
_jdbcSessionIdMgr |
protected long |
_saveIntervalSec |
protected JDBCSessionIdManager.SessionTableSchema |
_sessionTableSchema |
__defaultSessionTrackingModes, __distantFuture, _checkingRemoteSessionIdEncoding, _context, _dftMaxIdleSecs, _httpOnly, _loader, _maxCookieAge, _nodeIdInSessionId, _refreshCookieAge, _secureCookies, _secureRequestOnly, _sessionAttributeListeners, _sessionComment, _sessionCookie, _sessionDomain, _sessionHandler, _sessionIdListeners, _sessionIdManager, _sessionIdPathParameterName, _sessionIdPathParameterNamePrefix, _sessionListeners, _sessionPath, _sessionsStats, _sessionTimeStats, _sessionTrackingModes, MAX_INACTIVE_MINUTESFAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty| Constructor and Description |
|---|
JDBCSessionManager() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addSession(AbstractSession session)
Add a newly created session to our in-memory list for this node and persist it.
|
void |
cacheInvalidate(JDBCSessionManager.Session session)
A method that can be implemented in subclasses to support
distributed caching of sessions.
|
protected void |
deleteSession(JDBCSessionManager.Session data)
Delete a session from the database.
|
void |
doStart()
Start the session manager.
|
void |
doStop()
Stop the session manager.
|
protected Set<String> |
expire(Set<String> sessionIds)
Expire any Sessions we have in memory matching the list of
expired Session ids.
|
protected void |
expireCandidates(Set<String> candidateIds) |
protected Set<String> |
getCandidateExpiredIds() |
long |
getSaveInterval() |
JDBCSessionManager.Session |
getSession(String idInCluster)
A session has been requested by its id on this node.
|
int |
getSessions()
Get the number of sessions.
|
protected void |
invalidateSession(String idInCluster)
Invalidate a session.
|
protected JDBCSessionManager.Session |
loadSession(String id,
String canonicalContextPath,
String vhost)
Load a session from the database
|
protected AbstractSession |
newSession(HttpServletRequest request)
Make a new Session.
|
protected AbstractSession |
newSession(String sessionId,
String rowId,
long created,
long accessed,
long maxInterval) |
boolean |
removeSession(AbstractSession session,
boolean invalidate)
Remove session from manager
|
protected boolean |
removeSession(String idInCluster)
Delete an existing session, both from the in-memory map and
the database.
|
void |
renewSessionId(String oldClusterId,
String oldNodeId,
String newClusterId,
String newNodeId)
Tell the HttpSessionIdListeners the id changed.
|
void |
setSaveInterval(long sec)
Set the time in seconds which is the interval between
saving the session access time to the database.
|
protected void |
shutdownSessions()
Prepare sessions for session manager shutdown
|
protected void |
storeSession(JDBCSessionManager.Session session)
Insert a session into the database.
|
protected void |
updateSession(JDBCSessionManager.Session data)
Update data on an existing persisted session.
|
protected void |
updateSessionNode(JDBCSessionManager.Session data)
Update the node on which the session was last seen to be my node.
|
access, addEventListener, addSession, clearEventListeners, complete, doSessionAttributeListeners, getClusterId, getContext, getContextHandler, getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getHttpOnly, getHttpSession, getMaxCookieAge, getMaxInactiveInterval, getMetaManager, getNodeId, getRefreshCookieAge, getSecureCookies, getSessionCookie, getSessionCookie, getSessionCookieConfig, getSessionDomain, getSessionHandler, getSessionIdManager, getSessionIdPathParameterName, getSessionIdPathParameterNamePrefix, getSessionPath, getSessionsMax, getSessionsTotal, getSessionTimeMax, getSessionTimeMean, getSessionTimeStdDev, getSessionTimeTotal, isCheckingRemoteSessionIdEncoding, isNodeIdInSessionId, isSecureRequestOnly, isUsingCookies, isUsingURLs, isValid, newHttpSession, removeEventListener, removeSession, setCheckingRemoteSessionIdEncoding, setHttpOnly, setMaxInactiveInterval, setNodeIdInSessionId, setRefreshCookieAge, setSecureRequestOnly, setSessionCookie, setSessionHandler, setSessionIdManager, setSessionIdPathParameterName, setSessionTrackingModes, setUsingCookies, statsResetaddBean, 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, 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, stopprotected JDBCSessionIdManager _jdbcSessionIdMgr
protected long _saveIntervalSec
protected JDBCSessionIdManager.SessionTableSchema _sessionTableSchema
public void setSaveInterval(long sec)
sec - the save interval in secondspublic long getSaveInterval()
public void cacheInvalidate(JDBCSessionManager.Session session)
session - the session to invalidatepublic JDBCSessionManager.Session getSession(String idInCluster)
getSession in class AbstractSessionManageridInCluster - The session ID in the cluster, stripped of any worker name.AbstractSessionManager.getSession(java.lang.String)public int getSessions()
getSessions in class AbstractSessionManagerAbstractSessionManager.getSessions()public void doStart()
throws Exception
doStart in class AbstractSessionManagerExceptionAbstractSessionManager.doStart()public void doStop()
throws Exception
doStop in class AbstractSessionManagerExceptionAbstractSessionManager.doStop()protected void shutdownSessions()
AbstractSessionManagershutdownSessions in class AbstractSessionManagerpublic void renewSessionId(String oldClusterId, String oldNodeId, String newClusterId, String newNodeId)
AbstractSessionManagerrenewSessionId in interface SessionManagerrenewSessionId in class AbstractSessionManageroldClusterId - the old cluster idoldNodeId - the old node idnewClusterId - the new cluster idnewNodeId - the new node idSessionManager.renewSessionId(java.lang.String, java.lang.String, java.lang.String, java.lang.String)protected void invalidateSession(String idInCluster)
idInCluster - the id in the clusterprotected boolean removeSession(String idInCluster)
removeSession in class AbstractSessionManagerAbstractSessionManager.removeSession(java.lang.String)protected void addSession(AbstractSession session)
addSession in class AbstractSessionManagerAbstractSessionManager.addSession(org.eclipse.jetty.server.session.AbstractSession)protected AbstractSession newSession(HttpServletRequest request)
newSession in class AbstractSessionManagerrequest - the request to build the session fromAbstractSessionManager.newSession(javax.servlet.http.HttpServletRequest)protected AbstractSession newSession(String sessionId, String rowId, long created, long accessed, long maxInterval)
public boolean removeSession(AbstractSession session, boolean invalidate)
removeSession in class AbstractSessionManagersession - The session to removeinvalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and
SessionIdManager.invalidateAll(String) should be called.protected Set<String> expire(Set<String> sessionIds)
sessionIds - the session ids to expireprotected JDBCSessionManager.Session loadSession(String id, String canonicalContextPath, String vhost) throws Exception
id - the idcanonicalContextPath - the canonical context pathvhost - the virtual hostException - if unable to load the sessionprotected void storeSession(JDBCSessionManager.Session session) throws Exception
session - the sessionException - if unable to store the sessionprotected void updateSession(JDBCSessionManager.Session data) throws Exception
data - the sessionException - if unable to update the sessionprotected void updateSessionNode(JDBCSessionManager.Session data) throws Exception
data - the sessionException - if unable to update the session nodeprotected void deleteSession(JDBCSessionManager.Session data) throws Exception
data - the session dataException - if unable to delete the sessionCopyright © 1995–2017 Webtide. All rights reserved.