Class HistoryFilter
- java.lang.Object
-
- sunlabs.brazil.proxy.HistoryFilter
-
public class HistoryFilter extends java.lang.Object implements Filter
TheHistoryFilter
is both aHandler
and aFilter
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 theHistoryFilter
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 theHistoryFilter
will be invoked as aFilter
and not aHandler
. The default value is "", which indicates that the "Content-Type" is not examined and that thisHistoryFilter
will be invoked as aHandler
.
- Version:
- 2.2
- Author:
- Colin Stevens (colin.stevens@sun.com)
-
-
-
Constructor Summary
Constructors Constructor Description HistoryFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
filter(Request request, MimeHeaders headers, byte[] content)
Returns the original content, since this filter does not change content.boolean
init(Server server, java.lang.String prefix)
Initializes this filter by reading all its configuration properties.boolean
respond(Request request)
If theadmin
prefix is seen, store the history information associated with the session in the request properties.boolean
shouldFilter(Request request, MimeHeaders headers)
Called when invoked as aFilter
.
-
-
-
Field Detail
-
urlPrefix
public java.lang.String urlPrefix
-
session
public java.lang.String session
-
nosession
public java.lang.String nosession
-
admin
public java.lang.String admin
-
filter
public Regexp filter
-
-
Method Detail
-
init
public boolean init(Server server, java.lang.String prefix)
Initializes this filter by reading all its configuration properties.It is an error if the
filter
is specified but malformed.
-
respond
public boolean respond(Request request)
If theadmin
prefix is seen, store the history information associated with the session in the request properties.If invoked as a
Handler
and the URL matches theprefix
, records this page's address in the history.
-
shouldFilter
public boolean shouldFilter(Request request, MimeHeaders headers)
Called when invoked as aFilter
. If the URL matches theprefix
and the returned "Content-Type" matches thefilter
, records this page's address in the history.- Specified by:
shouldFilter
in interfaceFilter
- Parameters:
request
- The in-progress HTTP request.headers
- The MIME headers from the result.- Returns:
false
indicating that thisFilter
does not want to modify the content.
-
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.- Specified by:
filter
in interfaceFilter
- Parameters:
request
- The finished HTTP request.headers
- The MIME headers generated by theHandler
.content
- The output from theHandler
that thisFilter
may rewrite.- Returns:
- The rewritten content. The
Filter
may return the originalcontent
unchanged. TheFilter
may returnnull
to indicate that theFilterHandler
should stop processing the request and should not return any content to the client.
-
-