org.mortbay.jetty.servlet
Class AbstractSessionManager
java.lang.Object
org.mortbay.component.AbstractLifeCycle
org.mortbay.jetty.servlet.AbstractSessionManager
- All Implemented Interfaces:
- Serializable, LifeCycle, 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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
__nullSessionContext
private static final HttpSessionContext __nullSessionContext
__distantFuture
public static final int __distantFuture
- See Also:
- Constant Field Values
__NEW_SESSION_ID
private static final String __NEW_SESSION_ID
- See Also:
- Constant Field Values
_dftMaxIdleSecs
private int _dftMaxIdleSecs
_httpOnly
protected boolean _httpOnly
_maxSessions
protected int _maxSessions
_minSessions
protected int _minSessions
_random
protected transient Random _random
_scavengePeriodMs
private int _scavengePeriodMs
_metaManager
private SessionManager.MetaManager _metaManager
_scavenger
private transient AbstractSessionManager.SessionScavenger _scavenger
_secureCookies
protected boolean _secureCookies
_sessionAttributeListeners
protected transient Object _sessionAttributeListeners
_sessionListeners
protected transient Object _sessionListeners
_sessions
protected transient Map _sessions
_usingCookies
private boolean _usingCookies
_workerName
private String _workerName
_loader
protected transient ClassLoader _loader
_context
protected transient ContextHandler.Context _context
AbstractSessionManager
public AbstractSessionManager()
AbstractSessionManager
public AbstractSessionManager(Random random)
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 SessionManager.MetaManager getMetaManager()
- Specified by:
getMetaManager
in interface SessionManager
- Returns:
- Returns the metaManager used for cross context session management
setMetaManager
public void setMetaManager(SessionManager.MetaManager 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
contextPath
- TODO
- Returns:
getSessionMap
public Map getSessionMap()
getSessions
public int getSessions()
getWorkerName
public String getWorkerName()
- Get the workname.
If set, the workername is dot appended to the session ID
and can be used to assist session affinity in a load balancer.
- Returns:
- String or null
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)
newSessionId
private String newSessionId(HttpServletRequest request,
long created)
removeEventListener
public void removeEventListener(EventListener listener)
- Specified by:
removeEventListener
in interface SessionManager
resetStats
public void resetStats()
scavenge
private void scavenge()
- Find sessions that have timed out and invalidate them.
This runs in the SessionScavenger thread.
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.
setWorkerName
public void setWorkerName(String workerName)
- Set the workname.
If set, the workername is dot appended to the session ID
and can be used to assist session affinity in a load balancer.
- Parameters:
workerName
-
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