Known Direct Subclasses
|
Class Overview
A filter used to pre- and post-process incoming requests. Pre-processing occurs
before the application's exchange handler is invoked, and post-processing
occurs after the exchange handler returns. Filters
are organised in chains, and are associated with HttpContext instances.
Each Filter in the chain, invokes the next filter within its own
doFilter() implementation. The final Filter in the chain invokes the applications
exchange handler.
Summary
Nested Classes |
class |
Filter.Chain |
a chain of filters associated with a HttpServer. |
Protected Constructors |
|
Filter()
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Protected Constructors
Public Methods
public
abstract
String
description
()
returns a short description of this Filter
Returns
- a string describing the Filter
public
abstract
void
doFilter
(HttpExchange exchange, Filter.Chain chain)
Asks this filter to pre/post-process the given exchange. The filter
can :-
- examine or modify the request headers
- filter the request body or the response body, by creating suitable
filter streams and calling
setStreams(InputStream, OutputStream)
- set attribute Objects in the exchange, which other filters or the
exchange handler can access.
- decide to either :-
- invoke the next filter in the chain, by calling
doFilter(HttpExchange)
- terminate the chain of invocation, by not calling
doFilter(HttpExchange)
- if option 1. above taken, then when doFilter() returns all subsequent
filters in the Chain have been called, and the response headers can be
examined or modified.
- if option 2. above taken, then this Filter must use the HttpExchange
to send back an appropriate response
Parameters
exchange
| the HttpExchange to be filtered. |
chain
| the Chain which allows the next filter to be invoked. |