Class StatusFilter

java.lang.Object
org.restlet.Restlet
org.restlet.routing.Filter
org.restlet.engine.application.StatusFilter
All Implemented Interfaces:
Uniform

public class StatusFilter extends Filter
Filter associating a response entity based on the status. In order to customize the default representation, just subclass this class and override the "getRepresentation" method.
If any exception occurs during the call handling, a "server internal error" status is automatically associated to the call. Of course, you can personalize the representation of this error. Also, if no status is set (null), then the "success OK" status is assumed. 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.
Author:
Jerome Louvel
  • Constructor Details

    • StatusFilter

      public StatusFilter(Context context, boolean overwriting)
      Constructor.
      Parameters:
      context - The context.
      overwriting - Indicates whether an existing representation should be overwritten.
    • StatusFilter

      public StatusFilter(Context context, StatusService statusService)
      Constructor from a status service.
      Parameters:
      context - The context.
      statusService - The helped status service.
  • Method Details

    • afterHandle

      public void afterHandle(Request request, Response response)
      Allows filtering after its handling by the target Restlet. If the status is not set, set Status.SUCCESS_OK by default. If this is an error status, try to get a representation of it with StatusService.toRepresentation(Status, Request, Response) .
      Overrides:
      afterHandle in class Filter
      Parameters:
      request - The request to handle.
      response - The response to update.
    • doHandle

      protected int doHandle(Request request, Response response)
      Handles the call by distributing it to the next Restlet. If a throwable is caught, the StatusService.toStatus(Throwable, Request, Response) method is invoked.
      Overrides:
      doHandle in class Filter
      Parameters:
      request - The request to handle.
      response - The response to update.
      Returns:
      The continuation status.
    • getStatusService

      public StatusService getStatusService()
      Returns the helped status service.
      Returns:
      The helped status service.
    • isOverwriting

      public boolean isOverwriting()
      Indicates if existing representations should be overwritten.
      Returns:
      True if existing representations should be overwritten.
    • setOverwriting

      public void setOverwriting(boolean overwriting)
      Indicates if existing representations should be overwritten.
      Parameters:
      overwriting - True if existing representations should be overwritten.
    • setStatusService

      public void setStatusService(StatusService statusService)
      Sets the helped status service.
      Parameters:
      statusService - The helped status service.