Class HistoryFilter
- java.lang.Object
-
- sunlabs.brazil.proxy.HistoryFilter
-
public class HistoryFilter extends java.lang.Object implements Filter
TheHistoryFilteris both aHandlerand aFilterthat keeps a record of all pages visited by a given session.The
HistoryFiltercan 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 theHistoryFilterwill 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
HistoryFilterto store the history information for the current Session in the request properties -
filter - If specified, then this is a
Regexppattern to match against the "Content-Type" of the result. Setting this also implies that theHistoryFilterwill be invoked as aFilterand not aHandler. The default value is "", which indicates that the "Content-Type" is not examined and that thisHistoryFilterwill 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.booleaninit(Server server, java.lang.String prefix)Initializes this filter by reading all its configuration properties.booleanrespond(Request request)If theadminprefix is seen, store the history information associated with the session in the request properties.booleanshouldFilter(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
filteris specified but malformed.
-
respond
public boolean respond(Request request)
If theadminprefix is seen, store the history information associated with the session in the request properties.If invoked as a
Handlerand 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 theprefixand the returned "Content-Type" matches thefilter, records this page's address in the history.- Specified by:
shouldFilterin interfaceFilter- Parameters:
request- The in-progress HTTP request.headers- The MIME headers from the result.- Returns:
falseindicating that thisFilterdoes 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:
filterin interfaceFilter- Parameters:
request- The finished HTTP request.headers- The MIME headers generated by theHandler.content- The output from theHandlerthat thisFiltermay rewrite.- Returns:
- The rewritten content. The
Filtermay return the originalcontentunchanged. TheFiltermay returnnullto indicate that theFilterHandlershould stop processing the request and should not return any content to the client.
-
-