org.mortbay.jetty.servlet

Class AbstractSessionManager

Implemented Interfaces:
LifeCycle, Serializable, SessionManager
Known Direct 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.mortbay.jetty.servlet.AbstractSessionManager.23Notifications is set to true, the 2.3 servlet spec notification style will be used.

Version:
$Id: AbstractSessionManager.java,v 1.51 2005/08/24 09:03:22 gregwilkins Exp $
Author:
Greg Wilkins (gregw)

Nested Class Summary

abstract 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 Random
_random
protected boolean
_secureCookies
protected ArrayList
_sessionAttributeListeners
protected ArrayList
_sessionListeners
protected Map
_sessions
protected boolean
_weakRandom

Fields inherited from interface org.mortbay.jetty.servlet.SessionManager

__MaxAge, __SessionCookie, __SessionDomain, __SessionPath, __SessionURL, __SessionUrlPrefix

Constructor Summary

AbstractSessionManager()
AbstractSessionManager(Random random)

Method Summary

void
addEventListener(EventListener listener)
boolean
getCrossContextSessionIDs()
boolean
getHttpOnly()
HttpSession
getHttpSession(String id)
int
getMaxInactiveInterval()
int
getMaxSessions()
int
getMinSessions()
Random
getRandom()
int
getScavengePeriod()
boolean
getSecureCookies()
Cookie
getSessionCookie(HttpSession session, boolean requestIsSecure)
Map
getSessionMap()
int
getSessions()
boolean
getUseRequestedId()
Deprecated. use getCrossContextSessionIDs session IDs
String
getWorkerName()
Get the workname.
void
initialize(ServletHandler handler)
boolean
isInvalidateGlobal()
boolean
isStarted()
HttpSession
newHttpSession(HttpServletRequest request)
protected abstract AbstractSessionManager.Session
newSession(HttpServletRequest request)
void
removeEventListener(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(Random random)
void
setScavengePeriod(int seconds)
void
setSecureCookies(boolean secureCookies)
void
setUseRequestedId(boolean useRequestedId)
Deprecated. use setCrossContextSessionIDs session IDs
void
setWorkerName(String workerName)
Set the workname.
void
start()
void
stop()

Field Details

__allSessions

protected static MultiMap __allSessions

__distantFuture

public static final int __distantFuture
Field Value:
628992000

_crossContextSessionIDs

protected boolean _crossContextSessionIDs

_handler

protected ServletHandler _handler

_httpOnly

protected boolean _httpOnly

_invalidateGlobal

protected boolean _invalidateGlobal

_maxSessions

protected int _maxSessions

_minSessions

protected int _minSessions

_random

protected Random _random

_secureCookies

protected boolean _secureCookies

_sessionAttributeListeners

protected ArrayList _sessionAttributeListeners

_sessionListeners

protected ArrayList _sessionListeners

_sessions

protected Map _sessions

_weakRandom

protected boolean _weakRandom

Constructor Details

AbstractSessionManager

public AbstractSessionManager()

AbstractSessionManager

public AbstractSessionManager(Random random)

Method Details

addEventListener

public void addEventListener(EventListener listener)
            throws IllegalArgumentException
Specified by:
addEventListener in interface SessionManager

getCrossContextSessionIDs

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

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()

getRandom

public Random getRandom()

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,
                               boolean requestIsSecure)
Specified by:
getSessionCookie in interface SessionManager

getSessionMap

public Map getSessionMap()

getSessions

public int getSessions()

getUseRequestedId

public boolean getUseRequestedId()

Deprecated. use getCrossContextSessionIDs session IDs

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

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

initialize

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

isInvalidateGlobal

public boolean isInvalidateGlobal()

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle

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()

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

setHttpOnly

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

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.

setMaxInactiveInterval

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

setRandom

public void setRandom(Random random)

setScavengePeriod

public void setScavengePeriod(int seconds)
Parameters:
seconds -

setSecureCookies

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

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

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 -

start

public void start()
            throws Exception
Specified by:
start in interface LifeCycle

stop

public void stop()
Specified by:
stop in interface LifeCycle

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.