Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jetty.server.session
Class AbstractSessionManager

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

All Implemented Interfaces:
  SessionManager, LifeCycle

Direct Known Subclasses:
  HashSessionManager, JDBCSessionManager

    public abstract class AbstractSessionManager

extends AbstractLifeCycle
implements SessionManager

An Abstract implementation of SessionManager. The partial implementation of SessionManager interface provides the majority of the handling required to implement a SessionManager. Concrete implementations of SessionManager based on AbstractSessionManager need only implement the newSession method to return a specialised version of the Session inner class that provides an attribute Map.

Nested Class Summary
`static class` | `AbstractSessionManager.NullSessionContext` Null returning implementation of HttpSessionContext
`class` | `AbstractSessionManager.Session` Implements `HttpSession` from the `javax.servlet` package.
`static interface` | `AbstractSessionManager.SessionIf` Interface that any session wrapper should implement so that SessionManager may access the Jetty session implementation.

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
`java.util.Set<SessionTrackingMode>` | `__defaultSessionTrackingModes`
`static int` | `__distantFuture`
`protected boolean` | `_checkingRemoteSessionIdEncoding`
`protected ContextHandler.Context` | `_context`
`protected int` | `_dftMaxIdleSecs`
`protected boolean` | `_httpOnly`
`protected java.lang.ClassLoader` | `_loader`
`protected int` | `_maxCookieAge`
`protected boolean` | `_nodeIdInSessionId`
`protected int` | `_refreshCookieAge`
`protected boolean` | `_secureCookies`
`protected java.lang.Object` | `_sessionAttributeListeners`
`protected java.lang.String` | `_sessionComment`
`protected java.lang.String` | `_sessionCookie`
`protected java.lang.String` | `_sessionDomain`
`protected SessionHandler` | `_sessionHandler`
`protected SessionIdManager` | `_sessionIdManager`
`protected java.lang.String` | `_sessionIdPathParameterName`
`protected java.lang.String` | `_sessionIdPathParameterNamePrefix`
`protected java.lang.Object` | `_sessionListeners`
`protected java.lang.String` | `_sessionPath`
`protected CounterStatistic` | `_sessionsStats`
`protected SampleStatistic` | `_sessionTimeStats`
`java.util.Set<SessionTrackingMode>` | `_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
`AbstractSessionManager()`

Method Summary
`HttpCookie` | `access(HttpSession session, boolean secure)` Called by the `SessionHandler` when a session is first accessed by a request.
`void` | `addEventListener(java.util.EventListener listener)` Adds an event listener for session-related events.
`protected abstract void` | `addSession(AbstractSessionManager.Session session)`
`protected void` | `addSession(AbstractSessionManager.Session 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` | `doStart()`
`void` | `doStop()`
`java.lang.String` | `getClusterId(HttpSession session)`
`java.util.Set<SessionTrackingMode>` | `getDefaultSessionTrackingModes()`
`java.util.Set<SessionTrackingMode>` | `getEffectiveSessionTrackingModes()`
`boolean` | `getHttpOnly()`
`HttpSession` | `getHttpSession(java.lang.String nodeId)` Returns the `HttpSession` with the given session id
`SessionIdManager` | `getIdManager()`
`int` | `getMaxInactiveInterval()`
`int` | `getMaxSessions()` Deprecated.
`SessionIdManager` | `getMetaManager()` Deprecated. use `getIdManager()`
`int` | `getMinSessions()` Deprecated. always returns 0. no replacement available.
`java.lang.String` | `getNodeId(HttpSession session)`
`int` | `getRefreshCookieAge()`
`abstract AbstractSessionManager.Session` | `getSession(java.lang.String idInCluster)` Get a known existing session
`HttpCookie` | `getSessionCookie(HttpSession session, java.lang.String contextPath, boolean requestIsSecure)` Gets a Cookie for a session.
`SessionCookieConfig` | `getSessionCookieConfig()`
`SessionHandler` | `getSessionHandler()`
`java.lang.String` | `getSessionIdPathParameterName()`
`java.lang.String` | `getSessionIdPathParameterNamePrefix()`
`abstract java.util.Map` | `getSessionMap()` Deprecated. Need to review if it is needed.
`int` | `getSessions()`
`int` | `getSessionsMax()`
`int` | `getSessionsTotal()`
`long` | `getSessionTimeMax()`
`double` | `getSessionTimeMean()`
`double` | `getSessionTimeStdDev()`
`long` | `getSessionTimeTotal()`
`protected abstract void` | `invalidateSessions()`
`boolean` | `isCheckingRemoteSessionIdEncoding()`
`boolean` | `isNodeIdInSessionId()`
`boolean` | `isUsingCookies()`
`boolean` | `isUsingURLs()`
`boolean` | `isValid(HttpSession session)`
`HttpSession` | `newHttpSession(HttpServletRequest request)` Create a new HttpSession for a request
`protected abstract AbstractSessionManager.Session` | `newSession(HttpServletRequest request)` Create a new session instance
`void` | `removeEventListener(java.util.EventListener listener)` Removes an event listener for for session-related events.
`void` | `removeSession(AbstractSessionManager.Session session, boolean invalidate)` Remove session from manager
`void` | `removeSession(HttpSession session, boolean invalidate)` Remove session from manager
`protected abstract boolean` | `removeSession(java.lang.String idInCluster)`
`void` | `resetStats()` Deprecated.
`void` | `setCheckingRemoteSessionIdEncoding(boolean remote)`
`void` | `setHttpOnly(boolean httpOnly)`
`void` | `setIdManager(SessionIdManager metaManager)` Sets the cross context session id manager
`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` | `setSecureCookies(boolean secureCookies)` Set if the session manager should use SecureCookies.
`void` | `setSessionCookie(java.lang.String cookieName)`
`void` | `setSessionDomain(java.lang.String domain)`
`void` | `setSessionHandler(SessionHandler sessionHandler)` Sets the `SessionHandler`.
`void` | `setSessionIdPathParameterName(java.lang.String param)` Sets the session id URL path parameter name.
`void` | `setSessionTrackingModes(java.util.Set<SessionTrackingMode> sessionTrackingModes)`
`void` | `statsReset()` Reset statistics values

Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`addLifeCycleListener, 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

### __defaultSessionTrackingModes

    public java.util.Set<SessionTrackingMode> __defaultSessionTrackingModes

### __distantFuture

    public static final int __distantFuture

See Also:
  Constant Field Values

### _dftMaxIdleSecs

    protected int _dftMaxIdleSecs

### _sessionHandler

    protected SessionHandler _sessionHandler

### _httpOnly

    protected boolean _httpOnly

### _sessionIdManager

    protected SessionIdManager _sessionIdManager

### _secureCookies

    protected boolean _secureCookies

### _sessionAttributeListeners

    protected java.lang.Object _sessionAttributeListeners

### _sessionListeners

    protected java.lang.Object _sessionListeners

### _loader

    protected java.lang.ClassLoader _loader

### _context

    protected ContextHandler.Context _context

### _sessionCookie

    protected java.lang.String _sessionCookie

### _sessionIdPathParameterName

    protected java.lang.String _sessionIdPathParameterName

### _sessionIdPathParameterNamePrefix

    protected java.lang.String _sessionIdPathParameterNamePrefix

### _sessionDomain

    protected java.lang.String _sessionDomain

### _sessionPath

    protected java.lang.String _sessionPath

### _maxCookieAge

    protected int _maxCookieAge

### _refreshCookieAge

    protected int _refreshCookieAge

### _nodeIdInSessionId

    protected boolean _nodeIdInSessionId

### _checkingRemoteSessionIdEncoding

    protected boolean _checkingRemoteSessionIdEncoding

### _sessionComment

    protected java.lang.String _sessionComment

### _sessionTrackingModes

    public java.util.Set<SessionTrackingMode> _sessionTrackingModes

### _sessionsStats

    protected final CounterStatistic _sessionsStats

### _sessionTimeStats

    protected final SampleStatistic _sessionTimeStats

Constructor Detail

### AbstractSessionManager

    public AbstractSessionManager()

Method Detail

### access

    public HttpCookie access(HttpSession session,
                             boolean secure)

  Description copied from interface: `SessionManager`
  Called by the `SessionHandler` when a session is first accessed by a request.

  Specified by:
    `access` in interface `SessionManager`
  Parameters:
    `session` - the session object
    `secure` - whether the request is secure or not
  Returns:
    the session cookie. If not null, this cookie should be set on the response to either migrate the session or to refresh a session cookie that may expire.
  See Also:
    `SessionManager.complete(HttpSession)`

### addEventListener

    public void addEventListener(java.util.EventListener listener)

  Description copied from interface: `SessionManager`
  Adds an event listener for session-related events.

  Specified by:
    `addEventListener` in interface `SessionManager`
  Parameters:
    `listener` - 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.
  See Also:
    `SessionManager.removeEventListener(EventListener)`

### clearEventListeners

    public void clearEventListeners()

  Description copied from interface: `SessionManager`
  Removes all event listeners for session-related events.

  Specified by:
    `clearEventListeners` in interface `SessionManager`
  See Also:
    `SessionManager.removeEventListener(EventListener)`

### complete

    public void complete(HttpSession session)

  Description copied from interface: `SessionManager`
  Called by the `SessionHandler` when a session is last accessed by a request.

  Specified by:
    `complete` in interface `SessionManager`
  Parameters:
    `session` - the session object
  See Also:
    `SessionManager.access(HttpSession, boolean)`

### doStart

    public void doStart()
                 throws java.lang.Exception

  Overrides:
    `doStart` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### doStop

    public void doStop()
                throws java.lang.Exception

  Overrides:
    `doStop` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### getHttpOnly

    public boolean getHttpOnly()

  Specified by:
    `getHttpOnly` in interface `SessionManager`
  Returns:
    Returns the httpOnly.
  See Also:
    `HttpCookie.isHttpOnly()`

### getHttpSession

    public HttpSession getHttpSession(java.lang.String nodeId)

  Description copied from interface: `SessionManager`
  Returns the `HttpSession` with the given session id

  Specified by:
    `getHttpSession` in interface `SessionManager`
  Parameters:
    `nodeId` - the session id
  Returns:
    the `HttpSession` with the corresponding id or null if no session with the given id exists

### getIdManager

    public SessionIdManager getIdManager()

  Specified by:
    `getIdManager` in interface `SessionManager`
  Returns:
    Returns the metaManager used for cross context session management
  See Also:
    `SessionManager.setIdManager(SessionIdManager)`

### getMaxInactiveInterval

    public int getMaxInactiveInterval()

  Specified by:
    `getMaxInactiveInterval` in interface `SessionManager`
  Returns:
    seconds
  See Also:
    `SessionManager.setMaxInactiveInterval(int)`

### getMaxSessions

    @Deprecated
    public int getMaxSessions()

  Deprecated.

  See Also:
    `getSessionsMax()`

### getSessionsMax

    public int getSessionsMax()

  Returns:
    maximum number of sessions

### getSessionsTotal

    public int getSessionsTotal()

  Returns:
    total number of sessions

### getMetaManager

    @Deprecated
    public SessionIdManager getMetaManager()

  Deprecated. use `getIdManager()`

### getMinSessions

    @Deprecated
    public int getMinSessions()

  Deprecated. always returns 0. no replacement available.

### getRefreshCookieAge

    public int getRefreshCookieAge()

### getSessionCookie

    public HttpCookie getSessionCookie(HttpSession session,
                                       java.lang.String contextPath,
                                       boolean requestIsSecure)

  Description copied from interface: `SessionManager`
  Gets a Cookie for a session.

  Specified by:
    `getSessionCookie` in interface `SessionManager`
  Parameters:
    `session` - 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).
  Returns:
    if this `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`.

### getSessionHandler

    public SessionHandler getSessionHandler()

  Returns:
    Returns the sessionHandler.

### getSessionMap

    public abstract java.util.Map getSessionMap()

  Deprecated. Need to review if it is needed.

### getSessions

    public int getSessions()

### getSessionIdPathParameterName

    public java.lang.String getSessionIdPathParameterName()

  Specified by:
    `getSessionIdPathParameterName` in interface `SessionManager`
  Returns:
    the URL path parameter name for session id URL rewriting, by default "jsessionid".
  See Also:
    `SessionManager.setSessionIdPathParameterName(String)`

### getSessionIdPathParameterNamePrefix

    public java.lang.String getSessionIdPathParameterNamePrefix()

  Specified by:
    `getSessionIdPathParameterNamePrefix` in interface `SessionManager`
  Returns:
    a formatted version of `SessionManager.getSessionIdPathParameterName()`, by default ";" + sessionIdParameterName + "=", for easier lookup in URL strings.
  See Also:
    `SessionManager.getSessionIdPathParameterName()`

### isValid

    public boolean isValid(HttpSession session)

  Specified by:
    `isValid` in interface `SessionManager`
  Parameters:
    `session` - the session to test for validity
  Returns:
    whether the given session is valid, that is, it has not been invalidated.

### getClusterId

    public java.lang.String getClusterId(HttpSession session)

  Specified by:
    `getClusterId` in interface `SessionManager`
  Parameters:
    `session` - the session object
  Returns:
    the unique id of the session within the cluster (without a node id extension)
  See Also:
    `SessionManager.getNodeId(HttpSession)`

### getNodeId

    public java.lang.String getNodeId(HttpSession session)

  Specified by:
    `getNodeId` in interface `SessionManager`
  Parameters:
    `session` - the session object
  Returns:
    the unique id of the session within the cluster, extended with an optional node id.
  See Also:
    `SessionManager.getClusterId(HttpSession)`

### newHttpSession

    public HttpSession newHttpSession(HttpServletRequest request)

  Create a new HttpSession for a request

  Specified by:
    `newHttpSession` in interface `SessionManager`
  Parameters:
    `request` - the HttpServletRequest containing the requested session id
  Returns:
    the new `HttpSession`

### removeEventListener

    public void removeEventListener(java.util.EventListener listener)

  Description copied from interface: `SessionManager`
  Removes an event listener for for session-related events.

  Specified by:
    `removeEventListener` in interface `SessionManager`
  Parameters:
    `listener` - the session event listener to remove
  See Also:
    `SessionManager.addEventListener(EventListener)`

### resetStats

    @Deprecated
    public void resetStats()

  Deprecated.

  See Also:
    `statsReset()`

### statsReset

    public void statsReset()

  Reset statistics values

### setHttpOnly

    public void setHttpOnly(boolean httpOnly)

  Parameters:
    `httpOnly` - The httpOnly to set.

### setIdManager

    public void setIdManager(SessionIdManager metaManager)

  Description copied from interface: `SessionManager`
  Sets the cross context session id manager

  Specified by:
    `setIdManager` in interface `SessionManager`
  Parameters:
    `metaManager` - The metaManager used for cross context session management.
  See Also:
    `SessionManager.getIdManager()`

### 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`
  Parameters:
    `seconds` -
  See Also:
    `SessionManager.getMaxInactiveInterval()`

### setRefreshCookieAge

    public void setRefreshCookieAge(int ageInSeconds)

### setSecureCookies

    public void setSecureCookies(boolean secureCookies)

  Set if the session manager should use SecureCookies. A secure cookie will only be sent by a browser on a secure (https) connection to avoid the concern of cookies being intercepted on non secure channels. For the cookie to be issued as secure, the `ServletRequest#isSecure()` method must return true. If SSL offload is used, then the AbstractConnector#customize(org.eclipse.jetty.io.EndPoint, Request) method can be used to force the request to be https, or the {@link AbstractConnector#setForwarded(boolean)} can be set to true, so that the X-Forwarded-Proto header is respected.

  If secure session cookies are used, then a session may not be shared between http and https requests.

  Parameters:
    `secureCookies` - If true, use secure cookies.

### setSessionCookie

    public void setSessionCookie(java.lang.String cookieName)

### setSessionDomain

    public void setSessionDomain(java.lang.String domain)

### setSessionHandler

    public void setSessionHandler(SessionHandler sessionHandler)

  Description copied from interface: `SessionManager`
  Sets the `SessionHandler`.

  Specified by:
    `setSessionHandler` in interface `SessionManager`
  Parameters:
    `sessionHandler` - The sessionHandler to set.

### setSessionIdPathParameterName

    public void setSessionIdPathParameterName(java.lang.String param)

  Description copied from interface: `SessionManager`
  Sets the session id URL path parameter name.

  Specified by:
    `setSessionIdPathParameterName` in interface `SessionManager`
  Parameters:
    `param` - the URL path parameter name for session id URL rewriting (null or "none" for no rewriting).
  See Also:
    `SessionManager.getSessionIdPathParameterName()`, `SessionManager.getSessionIdPathParameterNamePrefix()`

### addSession

    protected abstract void addSession(AbstractSessionManager.Session session)

### addSession

    protected void addSession(AbstractSessionManager.Session session,
                              boolean created)

  Add the session Registers the session with this manager and registers the session ID with the sessionIDManager;

### getSession

    public abstract AbstractSessionManager.Session getSession(java.lang.String idInCluster)

  Get a known existing session

  Parameters:
    `idInCluster` - The session ID in the cluster, stripped of any worker name.
  Returns:
    A Session or null if none exists.

### invalidateSessions

    protected abstract void invalidateSessions()

### newSession

    protected abstract AbstractSessionManager.Session newSession(HttpServletRequest request)

  Create a new session instance

  Parameters:
    `request` -
  Returns:
    the new session

### isNodeIdInSessionId

    public boolean isNodeIdInSessionId()

  Returns:
    true if the cluster node id (worker id) is returned as part of the session id by `HttpSession.getId()`. Default is false.

### setNodeIdInSessionId

    public void setNodeIdInSessionId(boolean nodeIdInSessionId)

  Parameters:
    `nodeIdInSessionId` - true if the cluster node id (worker id) will be returned as part of the session id by `HttpSession.getId()`. Default is false.

### removeSession

    public void removeSession(HttpSession session,
                              boolean invalidate)

  Remove session from manager

  Parameters:
    `session` - The session to remove
    `invalidate` - True if `HttpSessionListener.sessionDestroyed(HttpSessionEvent)` and `SessionIdManager.invalidateAll(String)` should be called.

### removeSession

    public void removeSession(AbstractSessionManager.Session session,
                              boolean invalidate)

  Remove session from manager

  Parameters:
    `session` - The session to remove
    `invalidate` - True if `HttpSessionListener.sessionDestroyed(HttpSessionEvent)` and `SessionIdManager.invalidateAll(String)` should be called.

### removeSession

    protected abstract boolean removeSession(java.lang.String idInCluster)

### getSessionTimeMax

    public long getSessionTimeMax()

  Returns:
    maximum amount of time session remained valid

### getDefaultSessionTrackingModes

    public java.util.Set<SessionTrackingMode> getDefaultSessionTrackingModes()

  Specified by:
    `getDefaultSessionTrackingModes` in interface `SessionManager`

### getEffectiveSessionTrackingModes

    public java.util.Set<SessionTrackingMode> getEffectiveSessionTrackingModes()

  Specified by:
    `getEffectiveSessionTrackingModes` in interface `SessionManager`

### setSessionTrackingModes

    public void setSessionTrackingModes(java.util.Set<SessionTrackingMode> sessionTrackingModes)

  Specified by:
    `setSessionTrackingModes` in interface `SessionManager`

### isUsingCookies

    public boolean isUsingCookies()

  Specified by:
    `isUsingCookies` in interface `SessionManager`
  Returns:
    whether the session management is handled via cookies.

### isUsingURLs

    public boolean isUsingURLs()

  Specified by:
    `isUsingURLs` in interface `SessionManager`
  Returns:
    whether the session management is handled via URLs.

### getSessionCookieConfig

    public SessionCookieConfig getSessionCookieConfig()

  Specified by:
    `getSessionCookieConfig` in interface `SessionManager`

### getSessionTimeTotal

    public long getSessionTimeTotal()

  Returns:
    total amount of time all sessions remained valid

### getSessionTimeMean

    public double getSessionTimeMean()

  Returns:
    mean amount of time session remained valid

### getSessionTimeStdDev

    public double getSessionTimeStdDev()

  Returns:
    standard deviation of amount of time session remained valid

### isCheckingRemoteSessionIdEncoding

    public boolean isCheckingRemoteSessionIdEncoding()

  Specified by:
    `isCheckingRemoteSessionIdEncoding` in interface `SessionManager`
  Returns:
    True if absolute URLs are check for remoteness before being session encoded.
  See Also:
    `SessionManager.isCheckingRemoteSessionIdEncoding()`

### setCheckingRemoteSessionIdEncoding

    public void setCheckingRemoteSessionIdEncoding(boolean remote)

  Specified by:
    `setCheckingRemoteSessionIdEncoding` in interface `SessionManager`
  Parameters:
    `remote` - True if absolute URLs are check for remoteness before being session encoded.
  See Also:
    `SessionManager.setCheckingRemoteSessionIdEncoding(boolean)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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