sunlabs.brazil.session

Class CacheManager

public class CacheManager extends SessionManager implements Handler

This 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:

tables
The number of Hashtables in the pool (defaults to 6)
size
The max number of entries in each table (defaults to 1000).

Version: %V% CacheManager.java

Author: Stephen Uhler (stephen.uhler@sun.com)

Method Summary
protected voidflush()
The active hashtable is too big, find the hashtable with the worst Score, clear it, and set it as the active table.
protected ObjectgetObj(Object session, Object ident)
booleaninit(Server server, String prefix)
Install this class as the session manager.
protected StringmakeKey(Object session, Object ident)
Invent a single key from the 2 separate ones
protected voidputObj(String key, Object value)
protected voidputObj(Object session, Object ident, Object value)
voidremoveObj(Object session, Object ident)
Remove an object from a session table.
booleanrespond(Request request)
Don't handle any URL requests (yet)

Method Detail

flush

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.

getObj

protected Object getObj(Object session, Object ident)

init

public boolean init(Server server, String prefix)
Install this class as the session manager. Get the number of tables, and the max size per table.

makeKey

protected String makeKey(Object session, Object ident)
Invent a single key from the 2 separate ones

putObj

protected void putObj(String key, Object value)

putObj

protected void putObj(Object session, Object ident, Object value)

removeObj

public void removeObj(Object session, Object ident)
Remove an object from a session table. Don't bother to remove the table if its empty

respond

public boolean respond(Request request)
Don't handle any URL requests (yet)