public class CacheManager extends SessionManager implements Handler
SessionManager
associates an object with a Session ID
to give Handlers the ability to maintain state that lasts for the
duration of a session instead of just for the duration of a request.
It should be installed as a handler, whoses init method will replace
the default session manager.
This version maintains a pool of hashtables. Once they all fill up - one of them gets tossed, causing any session info in it to be lost. It uses a simplified approximate LRU scheme. The default session manager doesn't loose any session information, but grows the heap without bound as the number of sessions increase.
properties:
sessions
Constructor and Description |
---|
CacheManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
flush()
The active hashtable is too big, find the hashtable
with the worst Score, clear it, and set it as the active table.
|
protected java.lang.Object |
getObj(java.lang.Object session,
java.lang.Object ident)
Returns the object associated with the given Session ID and ident.
|
boolean |
init(Server server,
java.lang.String prefix)
Install this class as the session manager.
|
protected java.lang.String |
makeKey(java.lang.Object session,
java.lang.Object ident)
Invent a single key from the 2 separate ones
|
protected void |
putObj(java.lang.Object session,
java.lang.Object ident,
java.lang.Object value)
Associates an object with a session id and ident.
|
protected void |
putObj(java.lang.String key,
java.lang.Object value) |
void |
removeObj(java.lang.Object session,
java.lang.Object ident)
Remove an object from a session table.
|
boolean |
respond(Request request)
Don't handle any URL requests (yet)
|
get, getSession, put, remove, setSessionManager
public boolean init(Server server, java.lang.String prefix)
init
in interface Handler
server
- The HTTP server that created this Handler
.
Typical Handler
s will use Server.props
to obtain run-time configuration information.prefix
- The handlers name.
The string this Handler
may prepend to all
of the keys that it uses to extract configuration information
from Server.props
. This is set (by the Server
and ChainHandler
) to help avoid configuration parameter
namespace collisions.true
if this Handler
initialized
successfully, false
otherwise. If
false
is returned, this Handler
should not be used.public boolean respond(Request request)
protected java.lang.Object getObj(java.lang.Object session, java.lang.Object ident)
SessionManager
getObj
in class SessionManager
protected void putObj(java.lang.String key, java.lang.Object value)
protected void putObj(java.lang.Object session, java.lang.Object ident, java.lang.Object value)
SessionManager
putObj
in class SessionManager
public void removeObj(java.lang.Object session, java.lang.Object ident)
removeObj
in class SessionManager
protected void flush()
protected java.lang.String makeKey(java.lang.Object session, java.lang.Object ident)
makeKey
in class SessionManager