org.eclipse.jetty.server.session
类 JDBCSessionManager

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.server.session.AbstractSessionManager
          继承者 org.eclipse.jetty.server.session.JDBCSessionManager
所有已实现的接口:
SessionManager, LifeCycle

public class JDBCSessionManager
extends AbstractSessionManager

JDBCSessionManager SessionManager that persists sessions to a database to enable clustering. Session data is persisted to the JettySessions table: rowId (unique in cluster: webapp name/path + virtualhost + sessionId) contextPath (of the context owning the session) sessionId (unique in a context) lastNode (name of node last handled session) accessTime (time in milliseconds session was accessed) lastAccessTime (previous time in milliseconds session was accessed) createTime (time in milliseconds session created) cookieTime (time in milliseconds session cookie created) lastSavedTime (last time in milliseconds session access times were saved) expiryTime (time in milliseconds that the session is due to expire) map (attribute map) As an optimization, to prevent thrashing the database, we do not persist the accessTime and lastAccessTime every time the session is accessed. Rather, we write it out every so often. The frequency is controlled by the saveIntervalSec field.


嵌套类摘要
protected  class JDBCSessionManager.ClassLoadingObjectInputStream
          ClassLoadingObjectInputStream Used to persist the session attribute map
 class JDBCSessionManager.Session
          Session Session instance.
 
从类 org.eclipse.jetty.server.session.AbstractSessionManager 继承的嵌套类/接口
AbstractSessionManager.SessionIf
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
protected  JDBCSessionIdManager _jdbcSessionIdMgr
           
protected  long _saveIntervalSec
           
 
从类 org.eclipse.jetty.server.session.AbstractSessionManager 继承的字段
__defaultSessionTrackingModes, __distantFuture, _checkingRemoteSessionIdEncoding, _context, _dftMaxIdleSecs, _httpOnly, _loader, _maxCookieAge, _nodeIdInSessionId, _refreshCookieAge, _secureCookies, _secureRequestOnly, _sessionAttributeListeners, _sessionComment, _sessionCookie, _sessionDomain, _sessionHandler, _sessionIdManager, _sessionIdPathParameterName, _sessionIdPathParameterNamePrefix, _sessionListeners, _sessionPath, _sessionsStats, _sessionTimeStats, _sessionTrackingModes, SESSION_KNOWN_ONLY_TO_AUTHENTICATED
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
从接口 org.eclipse.jetty.server.SessionManager 继承的字段
__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty
 
构造方法摘要
JDBCSessionManager()
           
 
方法摘要
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  void expire(List<?> sessionIds)
          Expire any Sessions we have in memory matching the list of expired Session ids.
 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  void invalidateSessions()
           
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.
 void 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 setSaveInterval(long sec)
          Set the time in seconds which is the interval between saving the session access time to the database.
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.
 
从类 org.eclipse.jetty.server.session.AbstractSessionManager 继承的方法
access, addEventListener, addSession, clearEventListeners, complete, doSessionAttributeListeners, getClusterId, getContext, getContextHandler, getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getHttpOnly, getHttpSession, getIdManager, getMaxCookieAge, getMaxInactiveInterval, getMaxSessions, getMetaManager, getMinSessions, getNodeId, getRefreshCookieAge, getSecureCookies, getSessionCookie, getSessionCookie, getSessionCookieConfig, getSessionDomain, getSessionHandler, getSessionIdManager, getSessionIdPathParameterName, getSessionIdPathParameterNamePrefix, getSessionMap, getSessionPath, getSessionsMax, getSessionsTotal, getSessionTimeMax, getSessionTimeMean, getSessionTimeStdDev, getSessionTimeTotal, isCheckingRemoteSessionIdEncoding, isNodeIdInSessionId, isSecureRequestOnly, isUsingCookies, isUsingURLs, isValid, newHttpSession, removeEventListener, removeSession, renewSession, resetStats, setCheckingRemoteSessionIdEncoding, setHttpOnly, setIdManager, setMaxInactiveInterval, setNodeIdInSessionId, setRefreshCookieAge, setSecureRequestOnly, setSessionCookie, setSessionHandler, setSessionIdManager, setSessionIdPathParameterName, setSessionTrackingModes, setUsingCookies, statsReset
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的方法
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

字段详细信息

_jdbcSessionIdMgr

protected JDBCSessionIdManager _jdbcSessionIdMgr

_saveIntervalSec

protected long _saveIntervalSec
构造方法详细信息

JDBCSessionManager

public JDBCSessionManager()
方法详细信息

setSaveInterval

public void setSaveInterval(long sec)
Set the time in seconds which is the interval between saving the session access time to the database. This is an optimization that prevents the database from being overloaded when a session is accessed very frequently. On session exit, if the session attributes have NOT changed, the time at which we last saved the accessed time is compared to the current accessed time. If the interval is at least saveIntervalSecs, then the access time will be persisted to the database. If any session attribute does change, then the attributes and the accessed time are persisted.

参数:
sec -

getSaveInterval

public long getSaveInterval()

cacheInvalidate

public void cacheInvalidate(JDBCSessionManager.Session session)
A method that can be implemented in subclasses to support distributed caching of sessions. This method will be called whenever the session is written to the database because the session data has changed. This could be used eg with a JMS backplane to notify nodes that the session has changed and to delete the session from the node's cache, and re-read it from the database.

参数:
session -

getSession

public JDBCSessionManager.Session getSession(String idInCluster)
A session has been requested by its id on this node. Load the session by id AND context path from the database. Multiple contexts may share the same session id (due to dispatching) but they CANNOT share the same contents. Check if last node id is my node id, if so, then the session we have in memory cannot be stale. If another node used the session last, then we need to refresh from the db. NOTE: this method will go to the database, so if you only want to check for the existence of a Session in memory, use _sessions.get(id) instead.

指定者:
AbstractSessionManager 中的 getSession
参数:
idInCluster - The session ID in the cluster, stripped of any worker name.
返回:
A Session or null if none exists.
另请参见:
AbstractSessionManager.getSession(java.lang.String)

getSessions

public int getSessions()
Get the number of sessions.

覆盖:
AbstractSessionManager 中的 getSessions
另请参见:
AbstractSessionManager.getSessions()

doStart

public void doStart()
             throws Exception
Start the session manager.

覆盖:
AbstractSessionManager 中的 doStart
抛出:
Exception
另请参见:
AbstractSessionManager.doStart()

doStop

public void doStop()
            throws Exception
Stop the session manager.

覆盖:
AbstractSessionManager 中的 doStop
抛出:
Exception
另请参见:
AbstractSessionManager.doStop()

invalidateSessions

protected void invalidateSessions()
指定者:
AbstractSessionManager 中的 invalidateSessions

invalidateSession

protected void invalidateSession(String idInCluster)
Invalidate a session.

参数:
idInCluster -

removeSession

protected boolean removeSession(String idInCluster)
Delete an existing session, both from the in-memory map and the database.

指定者:
AbstractSessionManager 中的 removeSession
另请参见:
AbstractSessionManager.removeSession(java.lang.String)

addSession

protected void addSession(AbstractSession session)
Add a newly created session to our in-memory list for this node and persist it.

指定者:
AbstractSessionManager 中的 addSession
另请参见:
AbstractSessionManager.addSession(org.eclipse.jetty.server.session.AbstractSession)

newSession

protected AbstractSession newSession(HttpServletRequest request)
Make a new Session.

指定者:
AbstractSessionManager 中的 newSession
返回:
the new session
另请参见:
AbstractSessionManager.newSession(javax.servlet.http.HttpServletRequest)

removeSession

public void removeSession(AbstractSession session,
                          boolean invalidate)
Remove session from manager

覆盖:
AbstractSessionManager 中的 removeSession
参数:
session - The session to remove
invalidate - True if HttpSessionListener.sessionDestroyed(HttpSessionEvent) and SessionIdManager.invalidateAll(String) should be called.

expire

protected void expire(List<?> sessionIds)
Expire any Sessions we have in memory matching the list of expired Session ids.

参数:
sessionIds -

loadSession

protected JDBCSessionManager.Session loadSession(String id,
                                                 String canonicalContextPath,
                                                 String vhost)
                                          throws Exception
Load a session from the database

参数:
id -
返回:
the session data that was loaded
抛出:
Exception

storeSession

protected void storeSession(JDBCSessionManager.Session session)
                     throws Exception
Insert a session into the database.

参数:
data -
抛出:
Exception

updateSession

protected void updateSession(JDBCSessionManager.Session data)
                      throws Exception
Update data on an existing persisted session.

参数:
data - the session
抛出:
Exception

updateSessionNode

protected void updateSessionNode(JDBCSessionManager.Session data)
                          throws Exception
Update the node on which the session was last seen to be my node.

参数:
data - the session
抛出:
Exception

deleteSession

protected void deleteSession(JDBCSessionManager.Session data)
                      throws Exception
Delete a session from the database. Should only be called when the session has been invalidated.

参数:
data -
抛出:
Exception


Copyright © 2013. All Rights Reserved.