Package org.restlet.engine.application
Class StatusFilter
java.lang.Object
org.restlet.Restlet
org.restlet.routing.Filter
org.restlet.engine.application.StatusFilter
- All Implemented Interfaces:
Uniform
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.
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
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionStatusFilter(Context context, boolean overwriting) Constructor.StatusFilter(Context context, StatusService statusService) Constructor from a status service. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterHandle(Request request, Response response) Allows filtering after its handling by the target Restlet.protected intHandles the call by distributing it to the next Restlet.Returns the helped status service.booleanIndicates if existing representations should be overwritten.voidsetOverwriting(boolean overwriting) Indicates if existing representations should be overwritten.voidsetStatusService(StatusService statusService) Sets the helped status service.Methods inherited from class org.restlet.routing.Filter
beforeHandle, getNext, handle, hasNext, setNext, setNext, start, stopMethods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
-
Constructor Details
-
StatusFilter
Constructor.- Parameters:
context- The context.overwriting- Indicates whether an existing representation should be overwritten.
-
StatusFilter
Constructor from a status service.- Parameters:
context- The context.statusService- The helped status service.
-
-
Method Details
-
afterHandle
Allows filtering after its handling by the target Restlet. If the status is not set, setStatus.SUCCESS_OKby default. If this is an error status, try to get a representation of it withStatusService.toRepresentation(Status, Request, Response).- Overrides:
afterHandlein classFilter- Parameters:
request- The request to handle.response- The response to update.
-
doHandle
Handles the call by distributing it to the next Restlet. If a throwable is caught, theStatusService.toStatus(Throwable, Request, Response)method is invoked. -
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
Sets the helped status service.- Parameters:
statusService- The helped status service.
-