|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.handler.ConfigFileHandler (view source)
public class ConfigFileHandler
Handler for manipulating per-user session state that can be represented as ASCII name/value pairs. The state for each session is stored in a file, which is expected to be in java properties format. If "prefix" is matched, the contents of the (usually cached) config file for the current session is added to the request properties. If the url matches the "set" property, the contents of the config file are changed based on the supplied query parameters (either GET of POST). If no config file exists for the session, one is created from a default properties file. Only properties already in the config file may be changed using the "set" method. If a "%" is specified in the file name, it is replaced by the SessionID property, if any, or "common" if sessions aren't used. This should be replaced with something more general, so we can have more arbitrary mappings between request and the session info.
The following request properties are used:
See also: SetTemplate
which is preferrable in most cases, providing a templated based
(instead of URL based)
mechanism for maintaining persistent properties.
Constructor Summary | |
---|---|
ConfigFileHandler()
|
Method Summary | |
---|---|
boolean |
init(Server server,
String prefix)
Make sure default properties exist before starting this handler, or that "match" is specified". |
boolean |
respond(Request request)
Extract the session state into the request object, optionally modifying the properties. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConfigFileHandler()
Method Detail |
---|
public boolean init(Server server, 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) throws IOException
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
.
IOException
- if there was an I/O error while sending the response to
the client. Typically, in that case, the Server
will (try to) send an error message to the client and then
close the client's connection.
The IOException
should not be used to silently
ignore problems such as being unable to access some
server-side resource (for example getting a
FileNotFoundException
due to not being able
to open a file). In that case, the Handler
's
duty is to turn that IOException
into a
HTTP response indicating, in this case, that a file could
not be found.
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |