org.restlet
Class Filter

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Filter
Direct Known Subclasses:
Guard, Route, Transformer

public abstract class Filter
extends Restlet

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.

Author:
Jerome Louvel (contact@noelios.com)

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  void beforeHandle(Request request, Response response)
          Allows filtering before processing by the next Restlet.
protected  void 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(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
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
 

Constructor Detail

Filter

public Filter()
Constructor.


Filter

public Filter(Context context)
Constructor.

Parameters:
context - The context.

Filter

public Filter(Context context,
              Restlet next)
Constructor.

Parameters:
context - The context.
next - The next Restlet.
Method Detail

afterHandle

protected void afterHandle(Request request,
                           Response response)
Allows filtering after processing by the next Restlet. Does nothing by default.

Parameters:
request - The request to handle.
response - The response to update.

beforeHandle

protected void beforeHandle(Request request,
                            Response response)
Allows filtering before processing by the next Restlet. Does nothing by default.

Parameters:
request - The request to handle.
response - The response to update.

doHandle

protected void doHandle(Request request,
                        Response response)
Handles the call by distributing it to the next Restlet.

Parameters:
request - The request to handle.
response - The response to update.

getNext

public Restlet getNext()
Returns the next Restlet.

Returns:
The next Restlet or null.

handle

public final 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. When the handling is completed, it finally invokes the afterHandle() method for post-filtering.

Overrides:
handle in class Restlet
Parameters:
request - The request to handle.
response - The response to update.

hasNext

public boolean hasNext()
Indicates if there is a next Restlet.

Returns:
True if there is a next Restlet.

setNext

public void setNext(Restlet next)
Sets the next Restlet.

Parameters:
next - The next Restlet.

setNext

public void setNext(Class<? extends Resource> targetClass)
Sets the next Restlet as a Finder for a given Resource class. When the call is delegated to the Finder instance, a new instance of the Resource class will be created and will actually handle the request.

Parameters:
targetClass - The target Resource class to attach.


Copyright © 2005-2007 Noelios Technologies.