sunlabs.brazil.handler
Class ConfigFileHandler
public
class
ConfigFileHandler
extends Object
implements Handler
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:
- prefix
- The URL prefix required for all documents
- set
- The url pattern to match setting properties.
Currently, it must also match "prefix".
- noContent
- a url, matching the "set" pattern that causes
a "204 no content" to be returned to the client
(experimental).
- name
- The name of the config file. the first "%" is replaced
by the current SessionID.
- default
- The default properties file to "seed" session properties
- glob
- Properties that match this "glob" pattern may be set
using the "set" pattern. If this property is specified,
the "default" property is optional.
- root
- The document root (no properties prefix required). If the
"name" or "default" properties don't start with a "/",
this is used as the current directory.
If "%" is specified in the file name, a new session file is
created only if 1) a property is changed from the default, and 2)
A cookie was received by the browser.
See also: SetTemplate
which is preferrable in most cases, providing a templated based
(instead of URL based)
mechanism for maintaining persistent properties.
Version: 2.2, 04/08/30
Author: Stephen Uhler
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. |
public boolean init(
Server server, String prefix)
Make sure default properties exist before starting this handler,
or that "match" is specified".
public boolean respond(
Request request)
Extract the session state into the request object, optionally
modifying the properties. If the properties are modified,
they are stored in a file for safe keeping.