org.openqa.jetty.jetty.servlet
Class AbstractSessionManager

java.lang.Object
  extended by org.openqa.jetty.jetty.servlet.AbstractSessionManager
All Implemented Interfaces:
java.io.Serializable, SessionManager, LifeCycle
Direct Known Subclasses:
HashSessionManager

public abstract class AbstractSessionManager
extends java.lang.Object
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.openqa.jetty.jetty.servlet.AbstractSessionManager.23Notifications is set to true, the 2.3 servlet spec notification style will be used.

Version:
$Id: AbstractSessionManager.java,v 1.53 2006/11/22 20:01:10 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
Serialized Form

Nested Class Summary
 class AbstractSessionManager.Session
           
 
Field Summary
protected static MultiMap __allSessions
           
static int __distantFuture
           
protected  boolean _crossContextSessionIDs
           
protected  ServletHandler _handler
           
protected  boolean _httpOnly
           
protected  boolean _invalidateGlobal
           
protected  int _maxSessions
           
protected  int _minSessions
           
protected  java.util.Random _random
           
protected  boolean _secureCookies
           
protected  java.util.ArrayList _sessionAttributeListeners
           
protected  java.util.ArrayList _sessionListeners
           
protected  java.util.Map _sessions
           
protected  boolean _weakRandom
           
 
Fields inherited from interface org.openqa.jetty.jetty.servlet.SessionManager
__MaxAge, __SessionCookie, __SessionDomain, __SessionPath, __SessionURL, __SessionUrlPrefix
 
Constructor Summary
AbstractSessionManager()
           
AbstractSessionManager(java.util.Random random)
           
 
Method Summary
 void addEventListener(java.util.EventListener listener)
          Add an event listener.
 boolean getCrossContextSessionIDs()
           
 boolean getHttpOnly()
           
 javax.servlet.http.HttpSession getHttpSession(java.lang.String id)
           
 int getMaxInactiveInterval()
           
 int getMaxSessions()
           
 int getMinSessions()
           
 java.util.Random getRandom()
           
 int getScavengePeriod()
           
 boolean getSecureCookies()
           
 javax.servlet.http.Cookie getSessionCookie(javax.servlet.http.HttpSession session, boolean requestIsSecure)
          Get a Cookie for a session.
 java.util.Map getSessionMap()
           
 int getSessions()
           
 boolean getUseRequestedId()
          Deprecated. use getCrossContextSessionIDs session IDs
 java.lang.String getWorkerName()
          Get the workname.
 void initialize(ServletHandler handler)
           
 boolean isInvalidateGlobal()
           
 boolean isStarted()
           
 javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
           
protected abstract  AbstractSessionManager.Session newSession(javax.servlet.http.HttpServletRequest request)
           
 void removeEventListener(java.util.EventListener listener)
           
 void resetStats()
           
 void setCrossContextSessionIDs(boolean useRequestedId)
          Set Cross Context sessions IDs This option activates a mode where a requested session ID can be used to create a new session.
 void setHttpOnly(boolean httpOnly)
           
 void setInvalidateGlobal(boolean global)
           
 void setMaxInactiveInterval(int seconds)
           
 void setRandom(java.util.Random random)
           
 void setScavengePeriod(int seconds)
           
 void setSecureCookies(boolean secureCookies)
           
 void setUseRequestedId(boolean useRequestedId)
          Deprecated. use setCrossContextSessionIDs session IDs
 void setWorkerName(java.lang.String workerName)
          Set the workname.
 void start()
          Start the LifeCycle.
 void stop()
          Stop the LifeCycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__distantFuture

public static final int __distantFuture
See Also:
Constant Field Values

__allSessions

protected static MultiMap __allSessions

_sessionListeners

protected transient java.util.ArrayList _sessionListeners

_sessionAttributeListeners

protected transient java.util.ArrayList _sessionAttributeListeners

_sessions

protected transient java.util.Map _sessions

_random

protected transient java.util.Random _random

_weakRandom

protected transient boolean _weakRandom

_handler

protected transient ServletHandler _handler

_minSessions

protected int _minSessions

_maxSessions

protected int _maxSessions

_crossContextSessionIDs

protected boolean _crossContextSessionIDs

_secureCookies

protected boolean _secureCookies

_httpOnly

protected boolean _httpOnly

_invalidateGlobal

protected boolean _invalidateGlobal
Constructor Detail

AbstractSessionManager

public AbstractSessionManager()

AbstractSessionManager

public AbstractSessionManager(java.util.Random random)
Method Detail

getUseRequestedId

public boolean getUseRequestedId()
Deprecated. use getCrossContextSessionIDs session IDs

Returns:
True if requested session ID are first considered for new

setUseRequestedId

public void setUseRequestedId(boolean useRequestedId)
Deprecated. use setCrossContextSessionIDs session IDs

Set Use Requested ID.

Parameters:
useRequestedId - True if requested session ID are first considered for new

getCrossContextSessionIDs

public boolean getCrossContextSessionIDs()
Returns:
True if cross context session IDs are first considered for new session IDs

setCrossContextSessionIDs

public void setCrossContextSessionIDs(boolean useRequestedId)
Set Cross Context sessions IDs This option activates a mode where a requested session ID can be used to create a new session. This facilitates the sharing of session cookies when cross context dispatches use sessions.

Parameters:
useRequestedId - True if cross context session ID are first considered for new session IDs

initialize

public void initialize(ServletHandler handler)
Specified by:
initialize in interface SessionManager

getSessionMap

public java.util.Map getSessionMap()

getSessions

public int getSessions()

getMinSessions

public int getMinSessions()

getMaxSessions

public int getMaxSessions()

resetStats

public void resetStats()

getHttpSession

public javax.servlet.http.HttpSession getHttpSession(java.lang.String id)
Specified by:
getHttpSession in interface SessionManager

newHttpSession

public javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
Specified by:
newHttpSession in interface SessionManager

getSessionCookie

public javax.servlet.http.Cookie getSessionCookie(javax.servlet.http.HttpSession session,
                                                  boolean requestIsSecure)
Description copied from interface: SessionManager
Get a Cookie for a session.

Specified by:
getSessionCookie in interface SessionManager
Returns:

newSession

protected abstract AbstractSessionManager.Session newSession(javax.servlet.http.HttpServletRequest request)

getWorkerName

public java.lang.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

setWorkerName

public void setWorkerName(java.lang.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 -

getMaxInactiveInterval

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

setMaxInactiveInterval

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

getScavengePeriod

public int getScavengePeriod()
Returns:
seconds

setScavengePeriod

public void setScavengePeriod(int seconds)
Parameters:
seconds -

getHttpOnly

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

setHttpOnly

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

getSecureCookies

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

setSecureCookies

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

isInvalidateGlobal

public boolean isInvalidateGlobal()

setInvalidateGlobal

public void setInvalidateGlobal(boolean global)
Parameters:
global - True if session invalidation should be global. ie Sessions in other contexts with the same ID (linked by cross context dispatch or shared session cookie) are invalidated as a group.

addEventListener

public void addEventListener(java.util.EventListener listener)
                      throws java.lang.IllegalArgumentException
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
Throws:
java.lang.IllegalArgumentException - If an unsupported listener is passed.

removeEventListener

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

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle
Returns:
True if the LifeCycle has been started.

start

public void start()
           throws java.lang.Exception
Description copied from interface: LifeCycle
Start the LifeCycle.

Specified by:
start in interface LifeCycle
Throws:
java.lang.Exception - An arbitrary exception may be thrown.

stop

public void stop()
Description copied from interface: LifeCycle
Stop the LifeCycle. The LifeCycle may wait for current activities to complete normally, but it can be interrupted.

Specified by:
stop in interface LifeCycle

getRandom

public java.util.Random getRandom()

setRandom

public void setRandom(java.util.Random random)


Copyright © 2011. All Rights Reserved.