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.mortbay.jetty.servlet
Class AbstractSessionManager

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.jetty.servlet.AbstractSessionManager

All Implemented Interfaces:
  LifeCycle, SessionManager

Direct Known Subclasses:
  HashSessionManager, TerracottaSessionManager

    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 specialized version of the Session inner class that provides an attribute Map.

If the property org.mortbay.jetty.servlet.AbstractSessionManager.23Notifications is set to true, the 2.3 servlet spec notification style will be used.

Author:
  Greg Wilkins (gregw)

Nested Class Summary
`static class` | `AbstractSessionManager.NullSessionContext` Null returning implementation of HttpSessionContext
`class` | `AbstractSessionManager.Session` Implements `javax.servlet.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 interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

Field Summary
`static int` | `__distantFuture`
`protected ContextHandler.SContext` | `_context`
`protected int` | `_dftMaxIdleSecs`
`protected boolean` | `_httpOnly`
`protected java.lang.ClassLoader` | `_loader`
`protected int` | `_maxCookieAge`
`protected int` | `_maxSessions`
`protected int` | `_minSessions`
`protected boolean` | `_nodeIdInSessionId`
`protected int` | `_refreshCookieAge`
`protected boolean` | `_secureCookies`
`protected java.lang.Object` | `_sessionAttributeListeners`
`protected java.lang.String` | `_sessionCookie`
`protected java.lang.String` | `_sessionDomain`
`protected SessionHandler` | `_sessionHandler`
`protected SessionIdManager` | `_sessionIdManager`
`protected java.lang.Object` | `_sessionListeners`
`protected java.lang.String` | `_sessionPath`
`protected java.lang.String` | `_sessionURL`
`protected java.lang.String` | `_sessionURLPrefix`

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

Fields inherited from interface org.mortbay.jetty.SessionManager
`__DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionURL, __MaxAgeProperty, __SessionCookieProperty, __SessionDomainProperty, __SessionPathProperty, __SessionURLProperty`

Constructor Summary
`AbstractSessionManager()`

Method Summary
`javax.servlet.http.Cookie` | `access(javax.servlet.http.HttpSession session, boolean secure)` Called by the `SessionHandler` when a session is access by a request
`void` | `addEventListener(java.util.EventListener listener)` Add an event listener.
`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()`
`void` | `complete(javax.servlet.http.HttpSession session)` Called by the `SessionHandler` when a reqeuest is not longer handling a session.
`void` | `doStart()`
`void` | `doStop()`
`java.lang.String` | `getClusterId(javax.servlet.http.HttpSession session)` Get the session cluster id
`boolean` | `getHttpOnly()`
`javax.servlet.http.HttpSession` | `getHttpSession(java.lang.String nodeId)`
`SessionIdManager` | `getIdManager()`
`int` | `getMaxCookieAge()`
`int` | `getMaxInactiveInterval()`
`int` | `getMaxSessions()`
`SessionIdManager` | `getMetaManager()` Deprecated. use `getIdManager()`
`int` | `getMinSessions()`
`java.lang.String` | `getNodeId(javax.servlet.http.HttpSession session)` Get the session node id
`int` | `getRefreshCookieAge()`
`boolean` | `getSecureCookies()`
`abstract AbstractSessionManager.Session` | `getSession(java.lang.String idInCluster)` Get a known existingsession
`java.lang.String` | `getSessionCookie()`
`javax.servlet.http.Cookie` | `getSessionCookie(javax.servlet.http.HttpSession session, java.lang.String contextPath, boolean requestIsSecure)` Get a Cookie for a session.
`java.lang.String` | `getSessionDomain()`
`SessionHandler` | `getSessionHandler()`
`abstract java.util.Map` | `getSessionMap()`
`java.lang.String` | `getSessionPath()`
`abstract int` | `getSessions()`
`java.lang.String` | `getSessionURL()`
`java.lang.String` | `getSessionURLPrefix()`
`protected abstract void` | `invalidateSessions()`
`boolean` | `isNodeIdInSessionId()`
`boolean` | `isUsingCookies()`
`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 AbstractSessionManager.Session` | `newSession(javax.servlet.http.HttpServletRequest request)` Create a new session instance
`void` | `removeEventListener(java.util.EventListener listener)`
`void` | `removeSession(AbstractSessionManager.Session session, boolean invalidate)` Remove session from manager
`void` | `removeSession(javax.servlet.http.HttpSession session, boolean invalidate)` Remove session from manager
`protected abstract void` | `removeSession(java.lang.String idInCluster)`
`void` | `resetStats()`
`void` | `setHttpOnly(boolean httpOnly)`
`void` | `setIdManager(SessionIdManager metaManager)`
`void` | `setMaxCookieAge(int maxCookieAgeInSeconds)`
`void` | `setMaxInactiveInterval(int seconds)`
`void` | `setMetaManager(SessionIdManager metaManager)` Deprecated. use `setIdManager(SessionIdManager)`
`void` | `setNodeIdInSessionId(boolean nodeIdInSessionId)`
`void` | `setRefreshCookieAge(int ageInSeconds)`
`void` | `setSecureCookies(boolean secureCookies)`
`void` | `setSessionCookie(java.lang.String cookieName)`
`void` | `setSessionDomain(java.lang.String domain)`
`void` | `setSessionHandler(SessionHandler sessionHandler)`
`void` | `setSessionPath(java.lang.String path)`
`void` | `setSessionURL(java.lang.String param)` Set the session ID URL parameter name
`void` | `setUsingCookies(boolean usingCookies)`

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, 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.mortbay.component.LifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Field Detail

### __distantFuture

    public static final int __distantFuture

See Also:
  Constant Field Values

### _dftMaxIdleSecs

    protected int _dftMaxIdleSecs

### _sessionHandler

    protected SessionHandler _sessionHandler

### _httpOnly

    protected boolean _httpOnly

### _maxSessions

    protected int _maxSessions

### _minSessions

    protected int _minSessions

### _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.SContext _context

### _sessionCookie

    protected java.lang.String _sessionCookie

### _sessionURL

    protected java.lang.String _sessionURL

### _sessionURLPrefix

    protected java.lang.String _sessionURLPrefix

### _sessionDomain

    protected java.lang.String _sessionDomain

### _sessionPath

    protected java.lang.String _sessionPath

### _maxCookieAge

    protected int _maxCookieAge

### _refreshCookieAge

    protected int _refreshCookieAge

### _nodeIdInSessionId

    protected boolean _nodeIdInSessionId

Constructor Detail

### AbstractSessionManager

    public AbstractSessionManager()

Method Detail

### access

    public javax.servlet.http.Cookie access(javax.servlet.http.HttpSession session,
                                            boolean secure)

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

  Specified by:
    `access` in interface `SessionManager`
  Returns:
    Cookie If non null, this cookie should be set on the response to either migrate the session or to refresh a cookie that may expire.

### addEventListener

    public void addEventListener(java.util.EventListener listener)

  Description copied from interface: `SessionManager`
  Add an event listener.

  Specified by:
    `addEventListener` in interface `SessionManager`
  Parameters:
    `listener` - An Event Listener. Individual SessionManagers implemetations may accept arbitrary listener types, but they are expected to at least handle HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionListener

### clearEventListeners

    public void clearEventListeners()

  Specified by:
    `clearEventListeners` in interface `SessionManager`

### complete

    public void complete(javax.servlet.http.HttpSession session)

  Description copied from interface: `SessionManager`
  Called by the `SessionHandler` when a reqeuest is not longer handling a session. Not this includes new sessions, so there may not be a matching call to `#access(HttpSession)`.

  Specified by:
    `complete` in interface `SessionManager`

### 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.

### getHttpSession

    public javax.servlet.http.HttpSession getHttpSession(java.lang.String nodeId)

  Specified by:
    `getHttpSession` in interface `SessionManager`

### getIdManager

    public SessionIdManager getIdManager()

  Specified by:
    `getIdManager` in interface `SessionManager`
  Returns:
    Returns the metaManager used for cross context session management

### getMaxCookieAge

    public int getMaxCookieAge()

  Specified by:
    `getMaxCookieAge` in interface `SessionManager`

### getMaxInactiveInterval

    public int getMaxInactiveInterval()

  Specified by:
    `getMaxInactiveInterval` in interface `SessionManager`
  Returns:
    seconds

### getMaxSessions

    public int getMaxSessions()

### getMetaManager

    public SessionIdManager getMetaManager()

  Deprecated. use `getIdManager()`

  Specified by:
    `getMetaManager` in interface `SessionManager`
  Returns:
    the cross context session id manager.

### getMinSessions

    public int getMinSessions()

### getRefreshCookieAge

    public int getRefreshCookieAge()

### getSecureCookies

    public boolean getSecureCookies()

  Specified by:
    `getSecureCookies` in interface `SessionManager`
  Returns:
    Returns the secureCookies.

### getSessionCookie

    public java.lang.String getSessionCookie()

  Specified by:
    `getSessionCookie` in interface `SessionManager`

### getSessionCookie

    public javax.servlet.http.Cookie getSessionCookie(javax.servlet.http.HttpSession session,
                                                      java.lang.String contextPath,
                                                      boolean requestIsSecure)

  Description copied from interface: `SessionManager`
  Get 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`.

### getSessionDomain

    public java.lang.String getSessionDomain()

  Specified by:
    `getSessionDomain` in interface `SessionManager`

### getSessionHandler

    public SessionHandler getSessionHandler()

  Returns:
    Returns the sessionHandler.

### getSessionMap

    public abstract java.util.Map getSessionMap()

### getSessionPath

    public java.lang.String getSessionPath()

  Specified by:
    `getSessionPath` in interface `SessionManager`

### getSessions

    public abstract int getSessions()

### getSessionURL

    public java.lang.String getSessionURL()

  Specified by:
    `getSessionURL` in interface `SessionManager`

### getSessionURLPrefix

    public java.lang.String getSessionURLPrefix()

  Specified by:
    `getSessionURLPrefix` in interface `SessionManager`

### isUsingCookies

    public boolean isUsingCookies()

  Specified by:
    `isUsingCookies` in interface `SessionManager`
  Returns:
    Returns the usingCookies.

### isValid

    public boolean isValid(javax.servlet.http.HttpSession session)

  Specified by:
    `isValid` in interface `SessionManager`

### getClusterId

    public java.lang.String getClusterId(javax.servlet.http.HttpSession session)

  Description copied from interface: `SessionManager`
  Get the session cluster id

  Specified by:
    `getClusterId` in interface `SessionManager`
  Returns:
    The unique id of the session within the cluster (without a node id extension)

### getNodeId

    public java.lang.String getNodeId(javax.servlet.http.HttpSession session)

  Description copied from interface: `SessionManager`
  Get the session node id

  Specified by:
    `getNodeId` in interface `SessionManager`
  Returns:
    The unique id of the session within the cluster, extended with an optional node id.

### newHttpSession

    public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)

  Create a new HttpSession for a request

  Specified by:
    `newHttpSession` in interface `SessionManager`

### removeEventListener

    public void removeEventListener(java.util.EventListener listener)

  Specified by:
    `removeEventListener` in interface `SessionManager`

### resetStats

    public void resetStats()

### setHttpOnly

    public void setHttpOnly(boolean httpOnly)

  Parameters:
    `httpOnly` - The httpOnly to set.

### setIdManager

    public void setIdManager(SessionIdManager metaManager)

  Specified by:
    `setIdManager` in interface `SessionManager`
  Parameters:
    `metaManager` - The metaManager used for cross context session management.

### setMaxCookieAge

    public void setMaxCookieAge(int maxCookieAgeInSeconds)

  Specified by:
    `setMaxCookieAge` in interface `SessionManager`

### setMaxInactiveInterval

    public void setMaxInactiveInterval(int seconds)

  Specified by:
    `setMaxInactiveInterval` in interface `SessionManager`
  Parameters:
    `seconds` -

### setMetaManager

    public void setMetaManager(SessionIdManager metaManager)

  Deprecated. use `setIdManager(SessionIdManager)`

### setRefreshCookieAge

    public void setRefreshCookieAge(int ageInSeconds)

### setSecureCookies

    public void setSecureCookies(boolean secureCookies)

  Parameters:
    `secureCookies` - The secureCookies to set.

### setSessionCookie

    public void setSessionCookie(java.lang.String cookieName)

  Specified by:
    `setSessionCookie` in interface `SessionManager`

### setSessionDomain

    public void setSessionDomain(java.lang.String domain)

  Specified by:
    `setSessionDomain` in interface `SessionManager`

### setSessionHandler

    public void setSessionHandler(SessionHandler sessionHandler)

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

### setSessionPath

    public void setSessionPath(java.lang.String path)

  Specified by:
    `setSessionPath` in interface `SessionManager`

### setSessionURL

    public void setSessionURL(java.lang.String param)

  Set the session ID URL parameter name

  Specified by:
    `setSessionURL` in interface `SessionManager`
  Parameters:
    `param` - The parameter name for session id URL rewriting (null or "none" for no rewriting).

### setUsingCookies

    public void setUsingCookies(boolean usingCookies)

  Parameters:
    `usingCookies` - The usingCookies to set.

### 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 existingsession

  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(javax.servlet.http.HttpServletRequest request)

  Create a new session instance

  Parameters:
    `request` -
  Returns:

### 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(javax.servlet.http.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 void removeSession(java.lang.String idInCluster)

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.