public class StatusService extends Service
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.Status.isError()
, the
getRepresentation(Status, Request, Response)
method is then invoked
to give your service a chance to override the default error page.setOverwriting(boolean)
method.Constructor and Description |
---|
StatusService()
Constructor.
|
StatusService(boolean enabled)
Constructor.
|
StatusService(boolean enabled,
ConverterService converterService,
MetadataService metadataService,
ConnegService connegService)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Filter |
createInboundFilter(Context context)
Create the filter that should be invoked for incoming calls.
|
ConnegService |
getConnegService()
Returns the service used to select the preferred variant.
|
java.lang.String |
getContactEmail()
Returns the email address to contact in case of error.
|
ConverterService |
getConverterService()
Returns the service used to convert between status/throwable and
representation.
|
Reference |
getHomeRef()
Returns the home URI to propose in case of error.
|
MetadataService |
getMetadataService()
Returns the service used to select the preferred variant.
|
Representation |
getRepresentation(Status status,
Request request,
Response response)
Deprecated.
Use
toRepresentation(Status, Request, Response)
instead. |
Status |
getStatus(java.lang.Throwable throwable,
Request request,
Response response)
Deprecated.
Use
toStatus(Throwable, Request, Response) instead. |
Status |
getStatus(java.lang.Throwable throwable,
Resource resource)
Deprecated.
Use
toStatus(Throwable, Resource) instead. |
boolean |
isOverwriting()
Indicates if an existing entity should be overwritten.
|
void |
setConnegService(ConnegService connegService)
Sets the service used to select the preferred variant.
|
void |
setContactEmail(java.lang.String contactEmail)
Sets the email address to contact in case of error.
|
void |
setConverterService(ConverterService converterService)
Sets the service used to convert between status/throwable and
representation.
|
void |
setHomeRef(Reference homeRef)
Sets the home URI to propose in case of error.
|
void |
setMetadataService(MetadataService metadataService)
Sets the service used to select the preferred variant.
|
void |
setOverwriting(boolean overwriting)
Indicates if an existing entity should be overwritten.
|
Representation |
toRepresentation(Status status,
Request request,
Response response)
Returns a representation for the given status.
|
Representation |
toRepresentation(Status status,
Resource resource)
Returns a representation for the given status.
|
Status |
toStatus(java.lang.Throwable throwable,
Request request,
Response response)
Returns a status for a given exception or error.
|
Status |
toStatus(java.lang.Throwable throwable,
Resource resource)
Returns a status for a given exception or error.
|
createOutboundFilter, getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, start, stop
public StatusService()
public StatusService(boolean enabled)
enabled
- True if the service has been enabled.public StatusService(boolean enabled, ConverterService converterService, MetadataService metadataService, ConnegService connegService)
enabled
- True if the service has been enabled.converterService
- The service used to convert between status/throwable and
representation.metadataService
- The service used to select the preferred variant.connegService
- The service used to select the preferred variant.public Filter createInboundFilter(Context context)
Service
createInboundFilter
in class Service
context
- The current context.public ConnegService getConnegService()
public java.lang.String getContactEmail()
public ConverterService getConverterService()
public Reference getHomeRef()
public MetadataService getMetadataService()
@Deprecated public Representation getRepresentation(Status status, Request request, Response response)
toRepresentation(Status, Request, Response)
instead.status
- The status to represent.request
- The request handled.response
- The response updated.@Deprecated public Status getStatus(java.lang.Throwable throwable, Request request, Response response)
toStatus(Throwable, Request, Response)
instead.ResourceException
. For other exceptions or errors,
it returns an Status.SERVER_ERROR_INTERNAL
status.throwable
- The exception or error caught.request
- The request handled.response
- The response updated.@Deprecated public Status getStatus(java.lang.Throwable throwable, Resource resource)
toStatus(Throwable, Resource)
instead.Status.SERVER_ERROR_INTERNAL
status and logs a severe message.throwable
- The exception or error caught.resource
- The parent resource.public boolean isOverwriting()
public void setConnegService(ConnegService connegService)
connegService
- The service used to select the preferred variant.public void setContactEmail(java.lang.String contactEmail)
contactEmail
- The email address to contact in case of error.public void setConverterService(ConverterService converterService)
converterService
- The service used to convert between status/throwable and
representation.public void setHomeRef(Reference homeRef)
homeRef
- The home URI to propose in case of error.public void setMetadataService(MetadataService metadataService)
metadataService
- The service used to select the preferred variant.public void setOverwriting(boolean overwriting)
overwriting
- True if an existing entity should be overwritten.public Representation toRepresentation(Status status, Request request, Response response)
Status
representation by default or a
Throwable
representation if the throwable is annotated
with Status
.status
- The status to represent.request
- The request handled.response
- The response updated.public Representation toRepresentation(Status status, Resource resource)
toRepresentation(Status, Request, Response)
status
- The status to represent.resource
- The parent resource.public Status toStatus(java.lang.Throwable throwable, Request request, Response response)
ResourceException
. For other exceptions or errors,
it returns an Status.SERVER_ERROR_INTERNAL
status.throwable
- The exception or error caught.request
- The request handled.response
- The response updated.public Status toStatus(java.lang.Throwable throwable, Resource resource)
Status.SERVER_ERROR_INTERNAL
status and logs a severe message.throwable
- The exception or error caught.resource
- The parent resource.Copyright © 2005-2024 Restlet.