|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Filter
public abstract class Filter
Restlet filtering calls before passing them to an attached Restlet. The
purpose is to do some pre-processing or post-processing on the calls going
through it before or after they are actually handled by an attached Restlet.
Also note that you can attach and detach targets while handling incoming
calls as the filter is ensured to be thread-safe.
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
Field Summary | |
---|---|
static int |
CONTINUE
Indicates that the request processing should continue normally. |
static int |
SKIP
Indicates that after the beforeHandle(Request, Response) method,
the request processing should skip the
doHandle(Request, Response) method to continue with the
afterHandle(Request, Response) method. |
static int |
STOP
Indicates that the request processing should stop and return the current response from the filter. |
Constructor Summary | |
---|---|
Filter()
Constructor. |
|
Filter(Context context)
Constructor. |
|
Filter(Context context,
Restlet next)
Constructor. |
Method Summary | |
---|---|
protected void |
afterHandle(Request request,
Response response)
Allows filtering after processing by the next Restlet. |
protected int |
beforeHandle(Request request,
Response response)
Allows filtering before processing by the next Restlet. |
protected int |
doHandle(Request request,
Response response)
Handles the call by distributing it to the next Restlet. |
Restlet |
getNext()
Returns the next Restlet. |
void |
handle(Request request,
Response response)
Handles a call by first invoking the beforeHandle() method for pre-filtering, then distributing the call to the next Restlet via the doHandle() method. |
boolean |
hasNext()
Indicates if there is a next Restlet. |
void |
setNext(java.lang.Class<? extends Resource> targetClass)
Sets the next Restlet as a Finder for a given Resource class. |
void |
setNext(Restlet next)
Sets the next Restlet. |
Methods inherited from class org.restlet.Restlet |
---|
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop |
Methods inherited from class org.restlet.Uniform |
---|
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CONTINUE
beforeHandle(Request, Response)
method, the
filter then invokes the doHandle(Request, Response)
method. If
returned from the doHandle(Request, Response)
method, the filter
then invokes the afterHandle(Request, Response)
method.
public static final int SKIP
beforeHandle(Request, Response)
method,
the request processing should skip the
doHandle(Request, Response)
method to continue with the
afterHandle(Request, Response)
method.
public static final int STOP
Constructor Detail |
---|
public Filter()
public Filter(Context context)
context
- The context.public Filter(Context context, Restlet next)
context
- The context.next
- The next Restlet.Method Detail |
---|
protected void afterHandle(Request request, Response response)
request
- The request to handle.response
- The response to update.protected int beforeHandle(Request request, Response response)
CONTINUE
by default.
request
- The request to handle.response
- The response to update.
CONTINUE
or
SKIP
or STOP
.protected int doHandle(Request request, Response response)
Status.SERVER_ERROR_INTERNAL
status is returned.
Returns CONTINUE
by default.
request
- The request to handle.response
- The response to update.
CONTINUE
or
STOP
.public Restlet getNext()
public final void handle(Request request, Response response)
handle
in class Restlet
request
- The request to handle.response
- The response to update.public boolean hasNext()
public void setNext(java.lang.Class<? extends Resource> targetClass)
targetClass
- The target Resource class to attach.public void setNext(Restlet next)
next
- The next Restlet.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |