org.mortbay.jetty.servlet
Class HashSessionIdManager

java.lang.Object
  extended by org.mortbay.component.AbstractLifeCycle
      extended by org.mortbay.jetty.servlet.HashSessionIdManager
All Implemented Interfaces:
LifeCycle, SessionIdManager

public class HashSessionIdManager
extends AbstractLifeCycle
implements SessionIdManager

HashSessionIdManager. An in-memory implementation of the session ID manager.


Field Summary
protected  Random _random
           
protected static String SESSION_ID_RANDOM_ALGORITHM
           
protected static String SESSION_ID_RANDOM_ALGORITHM_ALT
           
 
Constructor Summary
HashSessionIdManager()
           
HashSessionIdManager(Random random)
           
 
Method Summary
 void addSession(HttpSession session)
          Add a session to the list of known sessions for a given ID.
protected  void doStart()
           
protected  void doStop()
           
 String getClusterId(String nodeId)
          Get the session ID with any worker ID.
 String getNodeId(String clusterId, HttpServletRequest request)
          Get the session ID with any worker ID.
 Random getRandom()
           
 String getWorkerName()
          Get the workname.
 boolean idInUse(String id)
           
 void invalidateAll(String id)
          Call HttpSession.invalidate() on all known sessions for the given id.
 String newSessionId(HttpServletRequest request, long created)
           
 void removeSession(HttpSession session)
          Remove session from the list of known sessions for a given ID.
 void setRandom(Random random)
           
 void setWorkerName(String workerName)
          Set the workname.
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, 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, isStopped, isStopping, start, stop
 

Field Detail

SESSION_ID_RANDOM_ALGORITHM

protected static final String SESSION_ID_RANDOM_ALGORITHM
See Also:
Constant Field Values

SESSION_ID_RANDOM_ALGORITHM_ALT

protected static final String SESSION_ID_RANDOM_ALGORITHM_ALT
See Also:
Constant Field Values

_random

protected Random _random
Constructor Detail

HashSessionIdManager

public HashSessionIdManager()

HashSessionIdManager

public HashSessionIdManager(Random random)
Method Detail

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.

Specified by:
getWorkerName in interface SessionIdManager
Returns:
String or null

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 -

getNodeId

public String getNodeId(String clusterId,
                        HttpServletRequest request)
Get the session ID with any worker ID.

Specified by:
getNodeId in interface SessionIdManager
Parameters:
request -
clusterId - The ID of the session
Returns:
sessionId plus any worker ID.

getClusterId

public String getClusterId(String nodeId)
Get the session ID with any worker ID.

Specified by:
getClusterId in interface SessionIdManager
Parameters:
request -
Returns:
sessionId plus any worker ID.

doStart

protected void doStart()
Overrides:
doStart in class AbstractLifeCycle

doStop

protected void doStop()
Overrides:
doStop in class AbstractLifeCycle

idInUse

public boolean idInUse(String id)
Specified by:
idInUse in interface SessionIdManager
Parameters:
id - The session ID without any cluster node extension
Returns:
True if the session ID is in use by at least one context.

addSession

public void addSession(HttpSession session)
Description copied from interface: SessionIdManager
Add a session to the list of known sessions for a given ID.

Specified by:
addSession in interface SessionIdManager
Parameters:
session - The session

removeSession

public void removeSession(HttpSession session)
Description copied from interface: SessionIdManager
Remove session from the list of known sessions for a given ID.

Specified by:
removeSession in interface SessionIdManager

invalidateAll

public void invalidateAll(String id)
Description copied from interface: SessionIdManager
Call HttpSession.invalidate() on all known sessions for the given id.

Specified by:
invalidateAll in interface SessionIdManager
Parameters:
id - The session ID without any cluster node extension

newSessionId

public String newSessionId(HttpServletRequest request,
                           long created)
Specified by:
newSessionId in interface SessionIdManager
Returns:

getRandom

public Random getRandom()

setRandom

public void setRandom(Random random)