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.
|
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.
|
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(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.
In order to customize the default representation, this method can be overridden. |
Status |
toStatus(Throwable throwable,
Request request,
Response response)
Returns a status for a given exception or error.
|
Status |
toStatus(Throwable throwable,
Resource resource)
Returns a status for a given exception or error.
|
createOutboundFilter, getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, start, stoppublic 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)
ServicecreateInboundFilter in class Servicecontext - The current context.public ConnegService getConnegService()
public String getContactEmail()
public ConverterService getConverterService()
public Reference getHomeRef()
public MetadataService getMetadataService()
public boolean isOverwriting()
public void setConnegService(ConnegService connegService)
connegService - The service used to select the preferred variant.public void setContactEmail(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(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(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–2025. All rights reserved.