sunlabs.brazil.proxy

Class HistoryFilter

public class HistoryFilter extends Object implements Filter

The HistoryFilter is both a Handler and a Filter that keeps a record of all pages visited by a given session.

The HistoryFilter can be used to make a user's session "mobile" as follows: A user's history is normally stored with the browser being used, on the user's machine. If the user runs a different browser or goes to a different machine, the user's history will not be there. Instead, the user can access the web via a proxy that keeps track of their history. No matter which browser the user chooses or machine the user is at, a server running with the HistoryFilter will automatically remember and be able to present the user's history.

The history is kept with respect to a Session ID.

This filter uses the following configuration properties:

prefix
This handler will only process URLs beginning with this string. The default value is "", which matches all URLs.
session
The name of the request property that holds the Session ID. The default value is "SessionID".
nosession
The Session ID to use if the Session ID was not specified. The default value is "common".
admin
URLs beginning with this prefix cause the HistoryFilter to store the history information for the current Session in the request properties
filter
If specified, then this is a Regexp pattern to match against the "Content-Type" of the result. Setting this also implies that the HistoryFilter will be invoked as a Filter and not a Handler. The default value is "", which indicates that the "Content-Type" is not examined and that this HistoryFilter will be invoked as a Handler.

Version: 2.2

Author: Colin Stevens (colin.stevens@sun.com)

Field Summary
Stringadmin
Regexpfilter
Stringnosession
Stringsession
StringurlPrefix
Method Summary
byte[]filter(Request request, MimeHeaders headers, byte[] content)
Returns the original content, since this filter does not change content.
booleaninit(Server server, String prefix)
Initializes this filter by reading all its configuration properties.
booleanrespond(Request request)
If the admin prefix is seen, store the history information associated with the session in the request properties.
booleanshouldFilter(Request request, MimeHeaders headers)
Called when invoked as a Filter.

Field Detail

admin

public String admin

filter

public Regexp filter

nosession

public String nosession

session

public String session

urlPrefix

public String urlPrefix

Method Detail

filter

public byte[] filter(Request request, MimeHeaders headers, byte[] content)
Returns the original content, since this filter does not change content. Won't actually be invoked.

init

public boolean init(Server server, String prefix)
Initializes this filter by reading all its configuration properties.

It is an error if the filter is specified but malformed.

Parameters: server The HTTP server. prefix The configuration property prefix.

Returns: true if this filter initialized successfully, false otherwise.

respond

public boolean respond(Request request)
If the admin prefix is seen, store the history information associated with the session in the request properties.

If invoked as a Handler and the URL matches the prefix, records this page's address in the history.

Parameters: request The Request object that represents the HTTP request.

Returns: false, indicating that this respond method ran purely for its side effects.

shouldFilter

public boolean shouldFilter(Request request, MimeHeaders headers)
Called when invoked as a Filter. If the URL matches the prefix and the returned "Content-Type" matches the filter, records this page's address in the history.

Parameters: request The in-progress HTTP request. headers The MIME headers from the result.

Returns: false indicating that this Filter does not want to modify the content.