public class DefaultSessionIdManager extends ContainerLifeCycle implements SessionIdManager
HouseKeeper
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
protected HouseKeeper |
_houseKeeper |
protected boolean |
_ownHouseKeeper |
protected Random |
_random |
protected long |
_reseed |
protected Server |
_server |
protected boolean |
_weakRandom |
protected String |
_workerAttr |
protected String |
_workerName |
protected static AtomicLong |
COUNTER |
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
Constructor and Description |
---|
DefaultSessionIdManager(Server server) |
DefaultSessionIdManager(Server server,
Random random) |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
void |
expireAll(String id)
Remove an id from use by telling all contexts to remove a session with this id.
|
String |
getExtendedId(String clusterId,
HttpServletRequest request)
Get the session ID with any worker ID.
|
String |
getId(String extendedId)
Get the session ID without any worker ID.
|
Random |
getRandom() |
long |
getReseed() |
Server |
getServer() |
Set<SessionHandler> |
getSessionHandlers()
Get SessionManager for every context.
|
HouseKeeper |
getSessionHouseKeeper() |
String |
getWorkerName()
Get the workname.
|
void |
initRandom()
Set up a random number generator for the sessionids.
|
void |
invalidateAll(String id)
Invalidate all sessions on all contexts that share the same id.
|
boolean |
isIdInUse(String id) |
String |
newSessionId(HttpServletRequest request,
long created)
Create a new session id if necessary.
|
String |
newSessionId(long seedTerm) |
String |
renewSessionId(String oldClusterId,
String oldNodeId,
HttpServletRequest request)
Generate a new id for a session and update across
all SessionManagers.
|
void |
setRandom(Random random) |
void |
setReseed(long reseed)
Set the reseed probability.
|
void |
setServer(Server server) |
void |
setSessionHouseKeeper(HouseKeeper houseKeeper) |
void |
setWorkerName(String workerName)
Set the workername.
|
String |
toString() |
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
protected static final AtomicLong COUNTER
protected Random _random
protected boolean _weakRandom
protected String _workerName
protected String _workerAttr
protected long _reseed
protected Server _server
protected HouseKeeper _houseKeeper
protected boolean _ownHouseKeeper
public DefaultSessionIdManager(Server server)
server
- the server associated with the id managerpublic void setServer(Server server)
server
- the server associated with this id managerpublic Server getServer()
public void setSessionHouseKeeper(HouseKeeper houseKeeper)
setSessionHouseKeeper
in interface SessionIdManager
houseKeeper
- the housekeeperpublic HouseKeeper getSessionHouseKeeper()
getSessionHouseKeeper
in interface SessionIdManager
public String getWorkerName()
getWorkerName
in interface SessionIdManager
public void setWorkerName(String workerName)
workerName
- the name of the worker, if null it is coerced to empty stringpublic Random getRandom()
public void setRandom(Random random)
random
- a random number generator for generating idspublic long getReseed()
public void setReseed(long reseed)
reseed
- If non zero then when a random long modulo the reseed value == 1, the SecureRandom
will be reseeded.public String newSessionId(HttpServletRequest request, long created)
newSessionId
in interface SessionIdManager
request
- the request with the sesioncreated
- the timestamp for when the session was createdSessionIdManager.newSessionId(javax.servlet.http.HttpServletRequest, long)
public String newSessionId(long seedTerm)
seedTerm
- the seed for RNGpublic boolean isIdInUse(String id)
isIdInUse
in interface SessionIdManager
id
- The plain session ID (ie no workername extension)SessionIdManager.isIdInUse(java.lang.String)
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
Exception
AbstractLifeCycle.doStart()
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
Exception
AbstractLifeCycle.doStop()
public void initRandom()
public String getExtendedId(String clusterId, HttpServletRequest request)
getExtendedId
in interface SessionIdManager
clusterId
- the cluster idrequest
- the requestpublic String getId(String extendedId)
getId
in interface SessionIdManager
extendedId
- the session id with the worker extensionpublic void expireAll(String id)
expireAll
in interface SessionIdManager
id
- The session ID without any cluster node extensionSessionIdManager.expireAll(java.lang.String)
public void invalidateAll(String id)
SessionIdManager
invalidateAll
in interface SessionIdManager
id
- the session idpublic String renewSessionId(String oldClusterId, String oldNodeId, HttpServletRequest request)
renewSessionId
in interface SessionIdManager
oldClusterId
- the old plain session idoldNodeId
- the old fully qualified idrequest
- the request containing the sessionSessionIdManager.renewSessionId(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest)
public Set<SessionHandler> getSessionHandlers()
getSessionHandlers
in interface SessionIdManager
public String toString()
toString
in class Object
Object.toString()
Copyright © 1995–2017 Webtide. All rights reserved.