Package sunlabs.brazil.session
Class PropertiesCacheManager
- java.lang.Object
-
- sunlabs.brazil.session.SessionManager
-
- sunlabs.brazil.session.CacheManager
-
- sunlabs.brazil.session.PropertiesCacheManager
-
- All Implemented Interfaces:
java.io.Serializable,Handler
public class PropertiesCacheManager extends CacheManager implements Handler, java.io.Serializable
A version of the CacheManager that saves out any session state that is either a "java properties" object, or implements "Saveable" into a directory in the filesystem, one file per entry, then restores them on server startup. This is a "poor man's" serialization, that saves only ascii state represented in properties files. This permits a wider variety of changes to be made to the server code, yet still have the ability to read in the proper session information.Classes that are not properties files may implement "Saveable", which has the store() and load() methods from Properties; they are expected to generate and restore the state of the object in Properties format.
This handler/sessionManager can take an ascii-readable "snapshot" of the server state, for all state that is a java properties object (or implements Saveable). It doesn't perturb the existing state.
Properties:
- storeDir
- The directory to use to store the state files. It is created as needed when the state is saved. Defalts to "store".
- match
- A glob pattern that matches the url (or url?query if a query is used. Defaults to "*\?*save=true".
- filePrefix
- A prefix pattern to use for all session files. Defaults to the handler prefix.
- defer
- If set, the saved session information is not reconstructed upon startup. Only the list of sessions is read in; the session information is restored only when needed.
- Version:
- %V% PropertiesCacheManager.java
- Author:
- Stephen Uhler (stephen.uhler@sun.com)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePropertiesCacheManager.SaveableThis interface allows for persistence of non-properties session objects.
-
Field Summary
-
Fields inherited from class sunlabs.brazil.session.SessionManager
sessions
-
-
Constructor Summary
Constructors Constructor Description PropertiesCacheManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.ObjectgetObj(java.lang.Object session, java.lang.Object ident)If we have deferred session loading, check here and get it!booleaninit(Server server, java.lang.String prefix)Install this class as the session manager.booleanrespond(Request request)Don't handle any URL requests (yet)-
Methods inherited from class sunlabs.brazil.session.CacheManager
flush, makeKey, putObj, putObj, removeObj
-
Methods inherited from class sunlabs.brazil.session.SessionManager
get, getSession, put, remove, setSessionManager
-
-
-
-
Method Detail
-
init
public boolean init(Server server, java.lang.String prefix)
Description copied from class:CacheManagerInstall this class as the session manager. Get the number of tables, and the max size per table.- Specified by:
initin interfaceHandler- Overrides:
initin classCacheManager- Parameters:
server- The HTTP server that created thisHandler. TypicalHandlers will useServer.propsto obtain run-time configuration information.prefix- The handlers name. The string thisHandlermay prepend to all of the keys that it uses to extract configuration information fromServer.props. This is set (by theServerandChainHandler) to help avoid configuration parameter namespace collisions.- Returns:
trueif thisHandlerinitialized successfully,falseotherwise. Iffalseis returned, thisHandlershould not be used.
-
respond
public boolean respond(Request request)
Description copied from class:CacheManagerDon't handle any URL requests (yet)- Specified by:
respondin interfaceHandler- Overrides:
respondin classCacheManager- Parameters:
request- TheRequestobject that represents the HTTP request.- Returns:
trueif the request was handled. A request was handled if a response was supplied to the client, typically by callingRequest.sendResponse()orRequest.sendError.
-
getObj
protected java.lang.Object getObj(java.lang.Object session, java.lang.Object ident)If we have deferred session loading, check here and get it!- Overrides:
getObjin classCacheManager
-
-