|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.proxy.HistoryFilter (view source)
public class HistoryFilter
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
session
nosession
admin
HistoryFilter
to store the history information for the current Session in the
request properties
filter
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
.
Field Summary | |
---|---|
String |
admin
|
Regexp |
filter
|
String |
nosession
|
String |
session
|
String |
urlPrefix
|
Constructor Summary | |
---|---|
HistoryFilter()
|
Method Summary | |
---|---|
byte[] |
filter(Request request,
MimeHeaders headers,
byte[] content)
Returns the original content, since this filter does not change content. |
boolean |
init(Server server,
String prefix)
Initializes this filter by reading all its configuration properties. |
boolean |
respond(Request request)
If the admin 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 a Filter . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public String urlPrefix
public String session
public String nosession
public String admin
public Regexp filter
Constructor Detail |
---|
public HistoryFilter()
Method Detail |
---|
public boolean init(Server server, String prefix)
It is an error if the filter
is specified but malformed.
init
in interface Handler
server
- The HTTP server.prefix
- The configuration property prefix.
true
if this filter initialized successfully,
false
otherwise.public boolean respond(Request request)
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.
respond
in interface Handler
request
- The Request
object that represents the HTTP
request.
false
, indicating that this respond
method ran purely for its side effects.public boolean shouldFilter(Request request, MimeHeaders headers)
Filter
. If the URL matches the
prefix
and the returned "Content-Type" matches the
filter
, records this page's address in the history.
shouldFilter
in interface Filter
request
- The in-progress HTTP request.headers
- The MIME headers from the result.
false
indicating that this Filter
does not want to modify the content.public byte[] filter(Request request, MimeHeaders headers, byte[] content)
filter
in interface Filter
request
- The finished HTTP request.headers
- The MIME headers generated by the Handler
.content
- The output from the Handler
that this
Filter
may rewrite.
Filter
may return
the original content
unchanged. The
Filter
may return null
to indicate
that the FilterHandler
should stop processing the
request and should not return any content to the client.
|
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 |