|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
org.restlet.routing.Filter
org.restlet.engine.application.StatusFilter
public class StatusFilter
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.
Field Summary |
---|
Fields inherited from class org.restlet.routing.Filter |
---|
CONTINUE, SKIP, STOP |
Constructor Summary | |
---|---|
StatusFilter(Context context,
boolean overwriting,
String email,
Reference homeRef)
Constructor. |
|
StatusFilter(Context context,
StatusService statusService)
Constructor from a status service. |
Method Summary | |
---|---|
void |
afterHandle(Request request,
Response response)
Allows filtering after its handling by the target Restlet. |
protected int |
doHandle(Request request,
Response response)
Handles the call by distributing it to the next Restlet. |
String |
getContactEmail()
Returns the email address of the administrator to contact in case of error. |
protected Representation |
getDefaultRepresentation(Status status,
Request request,
Response response)
Returns a representation for the given status. In order to customize the default representation, this method can be overridden. |
Reference |
getHomeRef()
Returns the home URI to propose in case of error. |
protected Representation |
getRepresentation(Status status,
Request request,
Response response)
Returns a representation for the given status. In order to customize the default representation, this method can be overridden. |
protected Status |
getStatus(Throwable throwable,
Request request,
Response response)
Returns a status for a given exception or error. |
protected String |
getStatusInfo(Status status)
Returns the status information to display in the default representation. |
StatusService |
getStatusService()
Returns the helped status service. |
boolean |
isOverwriting()
Indicates if existing representations should be overwritten. |
void |
setContactEmail(String email)
Sets the email address of the administrator to contact in case of error. |
void |
setHomeRef(Reference homeRef)
Sets the home URI to propose in case of error. |
void |
setOverwriting(boolean overwriting)
Indicates if existing representations should be overwritten. |
void |
setStatusService(StatusService statusService)
Sets the helped status service. |
Methods inherited from class org.restlet.routing.Filter |
---|
beforeHandle, getNext, handle, hasNext, setNext, setNext, start, stop |
Methods 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StatusFilter(Context context, boolean overwriting, String email, Reference homeRef)
context
- The context.overwriting
- Indicates whether an existing representation should be
overwritten.email
- Email address of the administrator to contact in case of
error.homeRef
- The home URI to propose in case of error.public StatusFilter(Context context, StatusService statusService)
context
- The context.statusService
- The helped status service.Method Detail |
---|
public void afterHandle(Request request, Response response)
afterHandle
in class Filter
request
- The request to handle.response
- The response to update.protected int doHandle(Request request, Response response)
getStatus(Throwable, Request, Response)
method is
invoked.
doHandle
in class Filter
request
- The request to handle.response
- The response to update.
public String getContactEmail()
protected Representation getDefaultRepresentation(Status status, Request request, Response response)
status
- The status to represent.request
- The request handled.response
- The response updated.
public Reference getHomeRef()
protected Representation getRepresentation(Status status, Request request, Response response)
status
- The status to represent.request
- The request handled.response
- The response updated.
protected Status getStatus(Throwable throwable, Request request, Response response)
Status.SERVER_ERROR_INTERNAL
status including the related error
or exception and logs a severe message.
throwable
- The exception or error caught.request
- The request handled.response
- The response updated.
protected String getStatusInfo(Status status)
status
- The status.
getDefaultRepresentation(Status, Request, Response)
public StatusService getStatusService()
public boolean isOverwriting()
public void setContactEmail(String email)
email
- The email address.public void setHomeRef(Reference homeRef)
homeRef
- The home URI.public void setOverwriting(boolean overwriting)
overwriting
- True if existing representations should be overwritten.public void setStatusService(StatusService statusService)
statusService
- The helped status service.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |