org.mortbay.jetty.servlet
Class AbstractSessionManager

java.lang.Object
  extended byorg.mortbay.component.AbstractLifeCycle
      extended byorg.mortbay.jetty.servlet.AbstractSessionManager
All Implemented Interfaces:
LifeCycle, Serializable, SessionManager
Direct Known Subclasses:
HashSessionManager

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)
See Also:
Serialized Form

Nested Class Summary
static class AbstractSessionManager.NullSessionContext
          Null returning implementation of HttpSessionContext
 class AbstractSessionManager.Session
           
 
Field Summary
static int __distantFuture
           
protected  ContextHandler.Context _context
           
protected  boolean _httpOnly
           
protected  ClassLoader _loader
           
protected  boolean _maxAgeSet
           
protected  int _maxSessionCookieAge
           
protected  int _maxSessions
           
protected  int _minSessions
           
protected  boolean _secureCookies
           
protected  Object _sessionAttributeListeners
           
protected  String _sessionCookie
           
protected  String _sessionDomain
           
protected  Object _sessionListeners
           
protected  String _sessionPath
           
protected  Map _sessions
           
protected  String _sessionURL
           
protected  String _sessionURLPrefix
           
 
Fields inherited from interface org.mortbay.jetty.SessionManager
__DefaultMaxAge, __DefaultSessionCookie, __DefaultSessionDomain, __DefaultSessionURL, __MaxAgeProperty, __MaxAgeSystemProperty, __SessionCookieProperty, __SessionCookieSystemProperty, __SessionDomainProperty, __SessionPathProperty, __SessionURLProperty, __SessionURLSystemProperty
 
Constructor Summary
AbstractSessionManager()
           
 
Method Summary
 void access(HttpSession session)
          Called by the SessionHandler when a session is access by a request
 void addEventListener(EventListener listener)
          Add an event listener.
 void clearEventListeners()
           
 void complete(HttpSession session)
          Called by the SessionHandler when a reqeuest is not longer handling a session.
 void doStart()
           
 void doStop()
           
 boolean getHttpOnly()
           
 HttpSession getHttpSession(String id)
           
 int getMaxCookieAge()
           
 int getMaxInactiveInterval()
           
 int getMaxSessions()
           
 SessionIdManager getMetaManager()
           
 int getMinSessions()
           
 int getScavengePeriod()
           
 boolean getSecureCookies()
           
 String getSessionCookie()
           
 Cookie getSessionCookie(HttpSession session, String contextPath, boolean requestIsSecure)
          Get a Cookie for a session.
 String getSessionDomain()
           
 SessionHandler getSessionHandler()
           
 Map getSessionMap()
           
 String getSessionPath()
           
 int getSessions()
           
 String getSessionURL()
           
 String getSessionURLPrefix()
           
 boolean isUsingCookies()
           
 boolean isValid(HttpSession session)
           
 HttpSession newHttpSession(HttpServletRequest request)
           
protected abstract  AbstractSessionManager.Session newSession(HttpServletRequest request)
           
 void removeEventListener(EventListener listener)
           
 void resetStats()
           
 void setHttpOnly(boolean httpOnly)
           
 void setMaxInactiveInterval(int seconds)
           
 void setMaxSessionCookieAge(int maxCookieAge)
           
 void setMetaManager(SessionIdManager metaManager)
           
 void setScavengePeriod(int seconds)
           
 void setSecureCookies(boolean secureCookies)
           
 void setSessionCookie(String cookieName)
           
 void setSessionDomain(String domain)
           
 void setSessionHandler(SessionHandler sessionHandler)
           
 void setSessionPath(String path)
           
 void setSessionURL(String url)
           
 void setUsingCookies(boolean usingCookies)
           
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, 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
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 

Field Detail

__distantFuture

public static final int __distantFuture
See Also:
Constant Field Values

_httpOnly

protected boolean _httpOnly

_maxSessions

protected int _maxSessions

_minSessions

protected int _minSessions

_secureCookies

protected boolean _secureCookies

_sessionAttributeListeners

protected Object _sessionAttributeListeners

_sessionListeners

protected Object _sessionListeners

_sessions

protected Map _sessions

_loader

protected ClassLoader _loader

_context

protected ContextHandler.Context _context

_sessionCookie

protected String _sessionCookie

_sessionURL

protected String _sessionURL

_sessionURLPrefix

protected String _sessionURLPrefix

_sessionDomain

protected String _sessionDomain

_sessionPath

protected String _sessionPath

_maxSessionCookieAge

protected int _maxSessionCookieAge

_maxAgeSet

protected boolean _maxAgeSet
Constructor Detail

AbstractSessionManager

public AbstractSessionManager()
Method Detail

setSessionCookie

public void setSessionCookie(String cookieName)
Specified by:
setSessionCookie in interface SessionManager

getSessionCookie

public String getSessionCookie()
Specified by:
getSessionCookie in interface SessionManager

setSessionURL

public void setSessionURL(String url)
Specified by:
setSessionURL in interface SessionManager

getSessionURL

public String getSessionURL()
Specified by:
getSessionURL in interface SessionManager

getSessionURLPrefix

public String getSessionURLPrefix()
Specified by:
getSessionURLPrefix in interface SessionManager

setSessionDomain

public void setSessionDomain(String domain)
Specified by:
setSessionDomain in interface SessionManager

getSessionDomain

public String getSessionDomain()
Specified by:
getSessionDomain in interface SessionManager

setSessionPath

public void setSessionPath(String path)
Specified by:
setSessionPath in interface SessionManager

getSessionPath

public String getSessionPath()
Specified by:
getSessionPath in interface SessionManager

setMaxSessionCookieAge

public void setMaxSessionCookieAge(int maxCookieAge)
Specified by:
setMaxSessionCookieAge in interface SessionManager

getMaxCookieAge

public int getMaxCookieAge()
Specified by:
getMaxCookieAge in interface SessionManager

clearEventListeners

public void clearEventListeners()
Specified by:
clearEventListeners in interface SessionManager

addEventListener

public void addEventListener(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

getMetaManager

public SessionIdManager getMetaManager()
Specified by:
getMetaManager in interface SessionManager
Returns:
Returns the metaManager used for cross context session management

setMetaManager

public void setMetaManager(SessionIdManager metaManager)
Specified by:
setMetaManager in interface SessionManager
Parameters:
metaManager - The metaManager used for cross context session management.

getHttpOnly

public boolean getHttpOnly()
Specified by:
getHttpOnly in interface SessionManager
Returns:
Returns the httpOnly.

getHttpSession

public HttpSession getHttpSession(String id)
Specified by:
getHttpSession in interface SessionManager

getMaxInactiveInterval

public int getMaxInactiveInterval()
Specified by:
getMaxInactiveInterval in interface SessionManager
Returns:
seconds

getMaxSessions

public int getMaxSessions()

getMinSessions

public int getMinSessions()

getScavengePeriod

public int getScavengePeriod()
Returns:
seconds

getSecureCookies

public boolean getSecureCookies()
Specified by:
getSecureCookies in interface SessionManager
Returns:
Returns the secureCookies.

getSessionCookie

public Cookie getSessionCookie(HttpSession session,
                               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.

getSessionMap

public Map getSessionMap()

getSessions

public int getSessions()

isUsingCookies

public boolean isUsingCookies()
Returns:
Returns the usingCookies.

newHttpSession

public HttpSession newHttpSession(HttpServletRequest request)
Specified by:
newHttpSession in interface SessionManager

newSession

protected abstract AbstractSessionManager.Session newSession(HttpServletRequest request)

removeEventListener

public void removeEventListener(EventListener listener)
Specified by:
removeEventListener in interface SessionManager

resetStats

public void resetStats()

setHttpOnly

public void setHttpOnly(boolean httpOnly)
Parameters:
httpOnly - The httpOnly to set.

setMaxInactiveInterval

public void setMaxInactiveInterval(int seconds)
Specified by:
setMaxInactiveInterval in interface SessionManager
Parameters:
seconds -

setScavengePeriod

public void setScavengePeriod(int seconds)
Parameters:
seconds -

setSecureCookies

public void setSecureCookies(boolean secureCookies)
Parameters:
secureCookies - The secureCookies to set.

setUsingCookies

public void setUsingCookies(boolean usingCookies)
Parameters:
usingCookies - The usingCookies to set.

doStart

public void doStart()
             throws Exception
Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception

doStop

public void doStop()
            throws Exception
Overrides:
doStop in class AbstractLifeCycle
Throws:
Exception

access

public void access(HttpSession session)
Description copied from interface: SessionManager
Called by the SessionHandler when a session is access by a request

Specified by:
access in interface SessionManager

complete

public void complete(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 SessionManager.access(HttpSession).

Specified by:
complete in interface SessionManager

isValid

public boolean isValid(HttpSession session)
Specified by:
isValid in interface SessionManager

getSessionHandler

public SessionHandler getSessionHandler()
Returns:
Returns the sessionHandler.

setSessionHandler

public void setSessionHandler(SessionHandler sessionHandler)
Specified by:
setSessionHandler in interface SessionManager
Parameters:
sessionHandler - The sessionHandler to set.