org.eclipse.jetty.server.session

## Class HashSessionManager

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.server.session.AbstractSessionManager
    - - org.eclipse.jetty.server.session.HashSessionManager

- All Implemented Interfaces:
    SessionManager, LifeCycle

      public class HashSessionManager
      extends AbstractSessionManager

  An in-memory implementation of SessionManager.

  This manager supports saving sessions to disk, either periodically or at shutdown. Sessions can also have their content idle saved to disk to reduce the memory overheads of large idle sessions.

  This manager will create it's own Timer instance to scavenge threads, unless it discovers a shared Timer instance set as the "org.eclipse.jetty.server.session.timer" attribute of the ContextHandler.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `HashSessionManager.ClassLoadingObjectInputStream`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.server.session.AbstractSessionManager

      `AbstractSessionManager.SessionIf`

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ConcurrentMap<String,HashedSession>` | `_sessions`

    - ### Fields inherited from class 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`

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

    - ### Fields inherited from interface org.eclipse.jetty.server.SessionManager

      `__CheckRemoteSessionEncoding, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionIdPathParameterName, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionIdPathParameterNameProperty, __SessionPathProperty`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashSessionManager()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addSession(AbstractSession session)`
    `void` | `doStart()`
    `void` | `doStop()`
    `int` | `getIdleSavePeriod()`
    `int` | `getSavePeriod()`
    `int` | `getScavengePeriod()`
    `AbstractSession` | `getSession(String idInCluster)` Get a known existing session
    `int` | `getSessions()`
    `File` | `getStoreDirectory()`
    `protected void` | `invalidateSessions()`
    `boolean` | `isDeleteUnrestorableSessions()`
    `boolean` | `isLazyLoad()`
    `protected AbstractSession` | `newSession(javax.servlet.http.HttpServletRequest request)` Create a new session instance
    `protected AbstractSession` | `newSession(long created, long accessed, String clusterId)`
    `protected boolean` | `removeSession(String clusterId)`
    `HashedSession` | `restoreSession(InputStream is, HashedSession session)`
    `protected HashedSession` | `restoreSession(String idInCuster)`
    `void` | `restoreSessions()`
    `void` | `saveSessions(boolean reactivate)`
    `protected void` | `scavenge()` Find sessions that have timed out and invalidate them.
    `void` | `setDeleteUnrestorableSessions(boolean deleteUnrestorableSessions)`
    `void` | `setIdleSavePeriod(int seconds)` Configures the period in seconds after which a session is deemed idle and saved to save on session memory.
    `void` | `setLazyLoad(boolean lazyLoad)`
    `void` | `setMaxInactiveInterval(int seconds)` Sets the max period of inactivity, after which the session is invalidated, in seconds.
    `void` | `setSavePeriod(int seconds)`
    `void` | `setScavengePeriod(int seconds)`
    `void` | `setStoreDirectory(File dir)`

    - ### Methods inherited from class org.eclipse.jetty.server.session.AbstractSessionManager

      `access, addEventListener, addSession, clearEventListeners, complete, doSessionAttributeListeners, getClusterId, getContext, getContextHandler, getDefaultSessionTrackingModes, getEffectiveSessionTrackingModes, getHttpOnly, getHttpSession, getIdManager, getMaxInactiveInterval, getMaxSessions, getMetaManager, getMinSessions, getNodeId, getRefreshCookieAge, getSecureCookies, getSessionCookie, getSessionCookie, getSessionCookieConfig, getSessionDomain, getSessionHandler, getSessionIdManager, getSessionIdPathParameterName, getSessionIdPathParameterNamePrefix, getSessionMap, getSessionsMax, getSessionsTotal, getSessionTimeMax, getSessionTimeMean, getSessionTimeStdDev, getSessionTimeTotal, isCheckingRemoteSessionIdEncoding, isNodeIdInSessionId, isSecureRequestOnly, isUsingCookies, isUsingURLs, isValid, newHttpSession, removeEventListener, removeSession, removeSession, resetStats, setCheckingRemoteSessionIdEncoding, setHttpOnly, setIdManager, setNodeIdInSessionId, setRefreshCookieAge, setSecureRequestOnly, setSessionCookie, setSessionHandler, setSessionIdManager, setSessionIdPathParameterName, setSessionTrackingModes, setUsingCookies, statsReset`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

- - ### Field Detail

    - #### _sessions

          protected final ConcurrentMap<String,HashedSession> _sessions

  - ### Constructor Detail

    - #### HashSessionManager

          public HashSessionManager()

  - ### Method Detail

    - #### doStart

          public void doStart()
                       throws Exception

      Overrides:
        `doStart` in class `AbstractSessionManager`
      Throws:
        `Exception`

    - #### doStop

          public void doStop()
                      throws Exception

      Overrides:
        `doStop` in class `AbstractSessionManager`
      Throws:
        `Exception`

    - #### getScavengePeriod

          public int getScavengePeriod()

      Returns:
        the period in seconds at which a check is made for sessions to be invalidated.

    - #### getSessions

          public int getSessions()

      Overrides:
        `getSessions` in class `AbstractSessionManager`

    - #### getIdleSavePeriod

          public int getIdleSavePeriod()

      Returns:
        seconds Idle period after which a session is saved

    - #### setIdleSavePeriod

          public void setIdleSavePeriod(int seconds)

      Configures the period in seconds after which a session is deemed idle and saved to save on session memory. The session is persisted, the values attribute map is cleared and the session set to idled.
      Parameters:
        `seconds` - Idle period after which a session is saved

    - #### setMaxInactiveInterval

          public void setMaxInactiveInterval(int seconds)

      Description copied from interface: `SessionManager`
      Sets the max period of inactivity, after which the session is invalidated, in seconds.
      Specified by:
        `setMaxInactiveInterval` in interface `SessionManager`
      Overrides:
        `setMaxInactiveInterval` in class `AbstractSessionManager`
      Parameters:
        `seconds` - the max inactivity period, in seconds.
      See Also:
        `SessionManager.getMaxInactiveInterval()`

    - #### setSavePeriod

          public void setSavePeriod(int seconds)

      Parameters:
        `seconds` - the period is seconds at which sessions are periodically saved to disk

    - #### getSavePeriod

          public int getSavePeriod()

      Returns:
        the period in seconds at which sessions are periodically saved to disk

    - #### setScavengePeriod

          public void setScavengePeriod(int seconds)

      Parameters:
        `seconds` - the period in seconds at which a check is made for sessions to be invalidated.

    - #### scavenge

          protected void scavenge()

      Find sessions that have timed out and invalidate them. This runs in the SessionScavenger thread.

    - #### addSession

          protected void addSession(AbstractSession session)

      Specified by:
        `addSession` in class `AbstractSessionManager`

    - #### getSession

          public AbstractSession getSession(String idInCluster)

      Description copied from class: `AbstractSessionManager`
      Get a known existing session
      Specified by:
        `getSession` in class `AbstractSessionManager`
      Parameters:
        `idInCluster` - The session ID in the cluster, stripped of any worker name.
      Returns:
        A Session or null if none exists.

    - #### invalidateSessions

          protected void invalidateSessions()
                                     throws Exception

      Specified by:
        `invalidateSessions` in class `AbstractSessionManager`
      Throws:
        `Exception`

    - #### newSession

          protected AbstractSession newSession(javax.servlet.http.HttpServletRequest request)

      Description copied from class: `AbstractSessionManager`
      Create a new session instance
      Specified by:
        `newSession` in class `AbstractSessionManager`
      Returns:
        the new session

    - #### newSession

          protected AbstractSession newSession(long created,
                                   long accessed,
                                   String clusterId)

    - #### removeSession

          protected boolean removeSession(String clusterId)

      Specified by:
        `removeSession` in class `AbstractSessionManager`

    - #### setStoreDirectory

          public void setStoreDirectory(File dir)

    - #### getStoreDirectory

          public File getStoreDirectory()

    - #### setLazyLoad

          public void setLazyLoad(boolean lazyLoad)

    - #### isLazyLoad

          public boolean isLazyLoad()

    - #### isDeleteUnrestorableSessions

          public boolean isDeleteUnrestorableSessions()

    - #### setDeleteUnrestorableSessions

          public void setDeleteUnrestorableSessions(boolean deleteUnrestorableSessions)

    - #### restoreSessions

          public void restoreSessions()
                               throws Exception

      Throws:
        `Exception`

    - #### restoreSession

          protected HashedSession restoreSession(String idInCuster)

    - #### saveSessions

          public void saveSessions(boolean reactivate)
                            throws Exception

      Throws:
        `Exception`

    - #### restoreSession

          public HashedSession restoreSession(InputStream is,
                                     HashedSession session)
                                       throws Exception

      Throws:
        `Exception`

Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.