|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sunlabs.brazil.session.SessionManager | +--sunlabs.brazil.session.SerialPersist
The SerialPersist
class is a SessionManager
that uses Java object serialization to make a persistent store of the
session information for a server. See SessionManager
for a description of sessions.
This class uses the signal-handling capabilities of the Solaris-specific
sun.misc
package. When the program is interrupted by a
Ctrl-C (SIGINT), the current session information is serialized to
a "store" file. When the program is restarted, the session information
is restored from the store file.
To use this SessionManager
effectively, the developer should
try to ensure that only Serializable
objects are stored in
the session manager. With default object serialization, the developer
will get a runtime IOException if an object in the hierarchy is not
actually serializable, for example, if a (Serializable
)
Hashtable
contains an arbitrary non-serializable object.
This class will traverse the session hierarchy and attempt to remove
all non-serializable objects before writing to the store file. This
means that after restoring, the session information may not correspond
exactly to what it was present before. Consumers of session information
should be prepared to deal with some session information disappearing.
For instance, the TemplateRunner
keeps the templates for each
session in the SessionManager
and will reconstruct the
templates if some or all of them disappear during a restore.
This class will recursively traverse the elements of (specifically) any
Hashtable
, Vector
, or array it finds in the
session hierarchy to ensure that the elements themselves are
Serializable
. If the element is not, it is removed from
its container. If the container becomes zero-length because all its
elements were removed, the container is then itself removed. For
arrays, the offending non-serializable element is instead replaced with
null
, since arrays cannot be resized.
SessionManager
implements the Handler
interface,and examines the following request properties at init time:
"store"
.
Field Summary |
Fields inherited from interface sun.misc.SignalHandler |
SIG_DFL, SIG_IGN |
Constructor Summary | |
SerialPersist()
|
Method Summary | |
static Object |
cleanForSerialization(Object obj)
Recursively decend through an object "Cleaning" it for serialization. |
void |
handle(sun.misc.Signal sig)
|
boolean |
init(Server server,
String prefix)
Initializes the handler. |
boolean |
respond(Request request)
Responds to an HTTP request. |
Methods inherited from class sunlabs.brazil.session.SessionManager |
get, getSession, put, remove, setSessionManager |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SerialPersist()
Method Detail |
public boolean init(Server server, String prefix)
Handler
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)
Handler
respond
in interface Handler
request
- The Request
object that represents the HTTP
request.
true
if the request was handled. A request was
handled if a response was supplied to the client, typically
by calling Request.sendResponse()
or
Request.sendError
.public void handle(sun.misc.Signal sig)
handle
in interface sun.misc.SignalHandler
public static Object cleanForSerialization(Object obj)
obj
- The object to Clean
|
Version 2.1, Generated 12/30/04 Copyright (c) 2001-2004, Sun Microsystems. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |