Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.jetty.servlet
Class AbstractSessionManager  view AbstractSessionManager download AbstractSessionManager.java

java.lang.Object
  extended byorg.mortbay.jetty.servlet.AbstractSessionManager
All Implemented Interfaces:
org.mortbay.util.LifeCycle, java.io.Serializable, SessionManager
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.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.35 2003/10/19 12:12:39 gregwilkins Exp $

Nested Class Summary
 class AbstractSessionManager.Session
           
(package private)  class AbstractSessionManager.SessionScavenger
          SessionScavenger is a background thread that kills off old sessions
 
Field Summary
static boolean __24SessionDestroyed
           
static int __distantFuture
           
private  int _dftMaxIdleSecs
           
protected  ServletHandler _handler
           
protected  int _maxSessions
           
protected  int _minSessions
           
protected  java.util.Random _random
           
private  int _scavengePeriodMs
           
private  AbstractSessionManager.SessionScavenger _scavenger
           
protected  java.util.ArrayList _sessionAttributeListeners
           
protected  java.util.ArrayList _sessionListeners
           
protected  java.util.Map _sessions
           
private  boolean _useRequestedId
           
private  java.lang.String _workerName
           
private static org.apache.commons.logging.Log log
           
 
Fields inherited from interface org.mortbay.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.
 javax.servlet.http.HttpSession getHttpSession(java.lang.String id)
           
 int getMaxInactiveInterval()
           
 int getMaxSessions()
           
 int getMinSessions()
           
 int getScavengePeriod()
           
 java.util.Map getSessionMap()
           
 int getSessions()
           
 boolean getUseRequestedId()
           
 java.lang.String getWorkerName()
          Get the workname.
 void initialize(ServletHandler handler)
           
 boolean isStarted()
           
 javax.servlet.http.HttpSession newHttpSession(javax.servlet.http.HttpServletRequest request)
           
protected abstract  AbstractSessionManager.Session newSession(javax.servlet.http.HttpServletRequest request)
           
private  java.lang.String newSessionId(javax.servlet.http.HttpServletRequest request, long created)
           
 void removeEventListener(java.util.EventListener listener)
           
 void resetStats()
           
private  void scavenge()
          Find sessions that have timed out and invalidate them.
 void setMaxInactiveInterval(int seconds)
           
 void setScavengePeriod(int seconds)
           
 void setUseRequestedId(boolean useRequestedId)
           
 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

log

private static org.apache.commons.logging.Log log

__distantFuture

public static final int __distantFuture
See Also:
Constant Field Values

__24SessionDestroyed

public static final boolean __24SessionDestroyed

_dftMaxIdleSecs

private int _dftMaxIdleSecs

_scavengePeriodMs

private int _scavengePeriodMs

_workerName

private java.lang.String _workerName

_useRequestedId

private boolean _useRequestedId

_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

_handler

protected transient ServletHandler _handler

_minSessions

protected int _minSessions

_maxSessions

protected int _maxSessions

_scavenger

private transient AbstractSessionManager.SessionScavenger _scavenger
Constructor Detail

AbstractSessionManager

public AbstractSessionManager()

AbstractSessionManager

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

getUseRequestedId

public boolean getUseRequestedId()

setUseRequestedId

public void setUseRequestedId(boolean useRequestedId)

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

newSessionId

private java.lang.String newSessionId(javax.servlet.http.HttpServletRequest request,
                                      long created)

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

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.


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.


getMaxInactiveInterval

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

setMaxInactiveInterval

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

getScavengePeriod

public int getScavengePeriod()

setScavengePeriod

public void setScavengePeriod(int seconds)

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

removeEventListener

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

isStarted

public boolean isStarted()
Specified by:
isStarted in interface org.mortbay.util.LifeCycle

start

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

Specified by:
start in interface org.mortbay.util.LifeCycle

stop

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

Specified by:
stop in interface org.mortbay.util.LifeCycle

scavenge

private void scavenge()
Find sessions that have timed out and invalidate them. This runs in the SessionScavenger thread.