public class AdaptingContainerResponse extends ContainerResponse
ContainerResponse
.Modifier and Type | Field and Description |
---|---|
protected ContainerResponse |
acr
The adapted container response.
|
Modifier | Constructor and Description |
---|---|
protected |
AdaptingContainerResponse(ContainerResponse acr)
Create the adapting container response.
|
Modifier and Type | Method and Description |
---|---|
java.lang.annotation.Annotation[] |
getAnnotations()
Get the annotations associated with the response entity (if any).
|
ContainerRequest |
getContainerRequest()
Get the container request.
|
ContainerResponseWriter |
getContainerResponseWriter()
Get the container response writer.
|
java.lang.Object |
getEntity() |
java.lang.reflect.Type |
getEntityType() |
MultivaluedMap<java.lang.String,java.lang.Object> |
getHttpHeaders()
Get the HTTP response headers.
|
java.lang.Throwable |
getMappedThrowable()
Get the throwable (if any) that was mapped to a response.
|
MediaType |
getMediaType()
Get the media type of the response entity.
|
MessageBodyWorkers |
getMessageBodyWorkers()
Get the message body workers.
|
java.lang.Object |
getOriginalEntity()
Get the original entity instance that was set by
HttpResponseContext.setEntity(java.lang.Object) . |
java.io.OutputStream |
getOutputStream()
Get an
OutputStream to which an entity may be written. |
Response |
getResponse()
Get the response that was set.
|
int |
getStatus() |
Response.StatusType |
getStatusType() |
boolean |
isCommitted()
Ascertain if a response has been committed to the container.
|
boolean |
isResponseSet()
Check if the response has been set using the setReponse methods.
|
boolean |
mapException(java.lang.Throwable e)
Map an exception to a response.
|
void |
mapMappableContainerException(MappableContainerException e)
Map the cause of a mappable container exception to a response.
|
void |
mapWebApplicationException(WebApplicationException e)
Map a web application exception to a response.
|
void |
reset()
Reset the response to 204 (No content) with no headers.
|
void |
setAnnotations(java.lang.annotation.Annotation[] annotations)
Set the annotations associated with the response entity (if any).
|
void |
setContainerRequest(ContainerRequest request)
Set the container request.
|
void |
setContainerResponseWriter(ContainerResponseWriter responseWriter)
Set the container response writer.
|
void |
setEntity(java.lang.Object entity)
Set the entity of the response.
|
void |
setEntity(java.lang.Object entity,
java.lang.reflect.Type entityType) |
void |
setResponse(Response response)
Set the response state from a Response instance.
|
void |
setStatus(int status)
Set the status of the response.
|
void |
setStatusType(Response.StatusType statusType)
Set the status type of the response.
|
void |
write()
Write the response.
|
getHeaderValue
protected final ContainerResponse acr
protected AdaptingContainerResponse(ContainerResponse acr)
acr
- the container response to adapt.public void write() throws java.io.IOException
ContainerResponse
The status and headers will be written by calling the method
ContainerResponseWriter.writeStatusAndHeaders(long, com.sun.jersey.spi.container.ContainerResponse)
on the provided
ContainerResponseWriter
instance. The OutputStream
returned from that method call is used to write the entity (if any)
to that OutputStream
. An appropriate MessageBodyWriter
will be found to write the entity.
write
in class ContainerResponse
java.io.IOException
- if there is an error writing the entitypublic void reset()
ContainerResponse
reset
in class ContainerResponse
public ContainerRequest getContainerRequest()
ContainerResponse
getContainerRequest
in class ContainerResponse
public void setContainerRequest(ContainerRequest request)
ContainerResponse
setContainerRequest
in class ContainerResponse
request
- the container request.public ContainerResponseWriter getContainerResponseWriter()
ContainerResponse
getContainerResponseWriter
in class ContainerResponse
public void setContainerResponseWriter(ContainerResponseWriter responseWriter)
ContainerResponse
setContainerResponseWriter
in class ContainerResponse
responseWriter
- the container response writerpublic MessageBodyWorkers getMessageBodyWorkers()
ContainerResponse
getMessageBodyWorkers
in class ContainerResponse
public void mapMappableContainerException(MappableContainerException e)
ContainerResponse
If the cause cannot be mapped and then that cause is re-thrown if a runtime exception otherwise the mappable container exception is re-thrown.
mapMappableContainerException
in class ContainerResponse
e
- the mappable container exception whose cause will be mapped to
a response.public void mapWebApplicationException(WebApplicationException e)
ContainerResponse
mapWebApplicationException
in class ContainerResponse
e
- the web application exception.public boolean mapException(java.lang.Throwable e)
ContainerResponse
mapException
in class ContainerResponse
e
- the exception.public Response getResponse()
HttpResponseContext
getResponse
in interface HttpResponseContext
getResponse
in class ContainerResponse
public void setResponse(Response response)
HttpResponseContext
setResponse
in interface HttpResponseContext
setResponse
in class ContainerResponse
response
- the response.public boolean isResponseSet()
HttpResponseContext
isResponseSet
in interface HttpResponseContext
isResponseSet
in class ContainerResponse
public java.lang.Throwable getMappedThrowable()
HttpResponseContext
getMappedThrowable
in interface HttpResponseContext
getMappedThrowable
in class ContainerResponse
public Response.StatusType getStatusType()
getStatusType
in interface HttpResponseContext
getStatusType
in class ContainerResponse
public void setStatusType(Response.StatusType statusType)
HttpResponseContext
setStatusType
in interface HttpResponseContext
setStatusType
in class ContainerResponse
statusType
- the status type.public int getStatus()
getStatus
in interface HttpResponseContext
getStatus
in class ContainerResponse
public void setStatus(int status)
HttpResponseContext
setStatus
in interface HttpResponseContext
setStatus
in class ContainerResponse
status
- the status.public java.lang.Object getEntity()
getEntity
in interface HttpResponseContext
getEntity
in class ContainerResponse
public java.lang.reflect.Type getEntityType()
getEntityType
in interface HttpResponseContext
getEntityType
in class ContainerResponse
public java.lang.Object getOriginalEntity()
HttpResponseContext
HttpResponseContext.setEntity(java.lang.Object)
.getOriginalEntity
in interface HttpResponseContext
getOriginalEntity
in class ContainerResponse
public void setEntity(java.lang.Object entity)
HttpResponseContext
If the entity is an instance of GenericEntity
then the entity
and entity type are set from the entity and type of that
GenericEntity
. Otherwise, the entity is set from the entity
parameter and the type is the class of that parameter.
If it is necessary to wrap an entity that may have been set with an
instance of GenericEntity
then utilize the
HttpResponseContext.getOriginalEntity()
, for example:
HttpResponseContext r = ... r.setEntity(wrap(getOriginalEntity()));
setEntity
in interface HttpResponseContext
setEntity
in class ContainerResponse
entity
- the entity.public void setEntity(java.lang.Object entity, java.lang.reflect.Type entityType)
setEntity
in class ContainerResponse
public java.lang.annotation.Annotation[] getAnnotations()
HttpResponseContext
getAnnotations
in interface HttpResponseContext
getAnnotations
in class ContainerResponse
public void setAnnotations(java.lang.annotation.Annotation[] annotations)
HttpResponseContext
setAnnotations
in interface HttpResponseContext
setAnnotations
in class ContainerResponse
annotations
- the annotations.public MultivaluedMap<java.lang.String,java.lang.Object> getHttpHeaders()
HttpResponseContext
HttpResponseContext.setResponse(javax.ws.rs.core.Response)
will replace any headers previously set.getHttpHeaders
in interface HttpResponseContext
getHttpHeaders
in class ContainerResponse
public MediaType getMediaType()
HttpResponseContext
getMediaType
in interface HttpResponseContext
getMediaType
in class ContainerResponse
public java.io.OutputStream getOutputStream() throws java.io.IOException
HttpResponseContext
OutputStream
to which an entity may be written.
The first byte written will result in the writing of thethe status code and headers.
getOutputStream
in interface HttpResponseContext
getOutputStream
in class ContainerResponse
java.io.IOException
- if an IO error occurspublic boolean isCommitted()
HttpResponseContext
A response is committed if the status code, headers have been written to the container.
isCommitted
in interface HttpResponseContext
isCommitted
in class ContainerResponse
Copyright © 2016 Oracle Corporation. All Rights Reserved.