| java.lang.Object org.restlet.service.StatusService
StatusService | public class StatusService (Code) | | Service to handle error statuses. If an exception is thrown within your
application or Restlet code, it will be intercepted by this service if it is
enabled.
When an exception or an error is caught, the
StatusService.getStatus(Throwable,Request,Response) method is first invoked to
obtain the status that you want to set on the response. If this method isn't
overridden or returns null, the
Status.SERVER_ERROR_INTERNAL constant
will be set by default.
Also, when the status of a response returned is an error status (see
Status.isError , the
StatusService.getRepresentation(Status,Request,Response) method is then invoked
to give your service a chance to override the default error page.
If you want to customize the default behavior, you need to create a subclass
of StatusService that overrides some or all of the methods mentioned above.
Then, just create a instance of your class and set it on your Component or
Application via the setStatusService() methods.
author: Jerome Louvel (contact@noelios.com) |
Constructor Summary | |
public | StatusService(boolean enabled) Constructor. |
StatusService | public StatusService(boolean enabled)(Code) | | Constructor.
Parameters: enabled - True if the service has been enabled. |
getContactEmail | public String getContactEmail()(Code) | | Returns the email address to contact in case of error. This is typically
used when creating the status representations.
The email address to contact in case of error. |
getHomeRef | public Reference getHomeRef()(Code) | | Returns the home URI to propose in case of error.
The home URI to propose in case of error. |
getRepresentation | public Representation getRepresentation(Status status, Request request, Response response)(Code) | | Returns a representation for the given status. In order to
customize the default representation, this method can be overriden. It
returns null by default.
Parameters: status - The status to represent. Parameters: request - The request handled. Parameters: response - The response updated. The representation of the given status. |
getStatus | public Status getStatus(Throwable throwable, Request request, Response response)(Code) | | Returns a status for a given exception or error. By default it returns an
Status.SERVER_ERROR_INTERNAL status and logs a severe message.
In order to customize the default behavior, this method can be overriden.
Parameters: throwable - The exception or error caught. Parameters: request - The request handled. Parameters: response - The response updated. The representation of the given status. |
isEnabled | public boolean isEnabled()(Code) | | Indicates if the service should be enabled.
True if the service should be enabled. |
isOverwrite | public boolean isOverwrite()(Code) | | Indicates if an existing entity should be overwritten. False by default.
True if an existing entity should be overwritten. |
setContactEmail | public void setContactEmail(String contactEmail)(Code) | | Sets the email address to contact in case of error. This is typically
used when creating the status representations.
Parameters: contactEmail - The email address to contact in case of error. |
setEnabled | public void setEnabled(boolean enabled)(Code) | | Indicates if the service should be enabled.
Parameters: enabled - True if the service should be enabled. |
setHomeRef | public void setHomeRef(Reference homeRef)(Code) | | Sets the home URI to propose in case of error.
Parameters: homeRef - The home URI to propose in case of error. |
setOverwrite | public void setOverwrite(boolean overwrite)(Code) | | Indicates if an existing entity should be overwritten.
Parameters: overwrite - True if an existing entity should be overwritten. |
|
|