Package org.glassfish.jersey.server
Class ContainerResponse
java.lang.Object
org.glassfish.jersey.server.ContainerResponse
- All Implemented Interfaces:
javax.ws.rs.container.ContainerResponseContext
public class ContainerResponse
extends Object
implements javax.ws.rs.container.ContainerResponseContext
Jersey container response context.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private final OutboundMessageContext
private final ContainerRequest
private javax.ws.rs.core.Response.StatusType
-
Constructor Summary
ConstructorsConstructorDescriptionContainerResponse
(ContainerRequest requestContext, javax.ws.rs.core.Response response) Create a new Jersey container response context.ContainerResponse
(ContainerRequest requestContext, OutboundJaxrsResponse response) Create a new Jersey container response context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the response.void
Commit theentity stream
unless already committed.void
enableBuffering
(javax.ws.rs.core.Configuration configuration) Enable a buffering of serialized entity.getDate()
Class
<?> javax.ws.rs.core.EntityTag
getHeaderString
(String name) int
javax.ws.rs.core.Link
javax.ws.rs.core.Link.Builder
getLinkBuilder
(String relation) Set
<javax.ws.rs.core.Link> getLinks()
javax.ws.rs.core.MediaType
Get the associated container request context paired with this response context.int
javax.ws.rs.core.Response.StatusType
Get the wrapped response message context.boolean
boolean
boolean
Returnstrue
if the response entity is aChunkedOutput
instance.boolean
Returnstrue
if the entity stream has been committed.boolean
Returns true if the response is result of the exception (for example created duringexception mapping
).void
Set a new message message entity.void
setEntity
(Object entity, Annotation[] annotations) Set a new message message entity.void
setEntity
(Object entity, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) void
setEntity
(Object entity, Type type, Annotation[] annotations) Set a new message message entity.void
setEntityAnnotations
(Annotation[] annotations) Set the annotations attached to the entity.void
setEntityStream
(OutputStream outputStream) void
setEntityType
(Type type) Set the message entity type information.void
setMappedFromException
(boolean mappedFromException) Sets the flag indicating whether the response was created based on the exception.void
setMediaType
(javax.ws.rs.core.MediaType mediaType) Set the message content media type.void
setStatus
(int code) void
setStatusInfo
(javax.ws.rs.core.Response.StatusType status) void
setStreamProvider
(OutboundMessageContext.StreamProvider streamProvider) Set the output stream provider callback.
-
Field Details
-
status
private javax.ws.rs.core.Response.StatusType status -
requestContext
-
messageContext
-
mappedFromException
private boolean mappedFromException -
closed
private boolean closed
-
-
Constructor Details
-
ContainerResponse
Create a new Jersey container response context.- Parameters:
requestContext
- associated container request context.response
- response instance initializing the response context.
-
ContainerResponse
ContainerResponse(ContainerRequest requestContext, OutboundJaxrsResponse response) Create a new Jersey container response context.- Parameters:
requestContext
- associated container request context.response
- response instance initializing the response context.
-
-
Method Details
-
isMappedFromException
public boolean isMappedFromException()Returns true if the response is result of the exception (for example created duringexception mapping
).- Returns:
- True if this response was created based on the exception, false otherwise.
-
setMappedFromException
public void setMappedFromException(boolean mappedFromException) Sets the flag indicating whether the response was created based on the exception.- Parameters:
mappedFromException
- True if this exception if result of the exception (for example result ofexception mapping
).
-
getStatus
public int getStatus()- Specified by:
getStatus
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setStatus
public void setStatus(int code) - Specified by:
setStatus
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setStatusInfo
public void setStatusInfo(javax.ws.rs.core.Response.StatusType status) - Specified by:
setStatusInfo
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getStatusInfo
public javax.ws.rs.core.Response.StatusType getStatusInfo()- Specified by:
getStatusInfo
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getRequestContext
Get the associated container request context paired with this response context.- Returns:
- associated container request context.
-
getCookies
- Specified by:
getCookies
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getWrappedMessageContext
Get the wrapped response message context.- Returns:
- wrapped response message context.
-
getHeaderString
- Specified by:
getHeaderString
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getHeaders
- Specified by:
getHeaders
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getStringHeaders
- Specified by:
getStringHeaders
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getDate
- Specified by:
getDate
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLanguage
- Specified by:
getLanguage
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getMediaType
public javax.ws.rs.core.MediaType getMediaType()- Specified by:
getMediaType
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getAllowedMethods
- Specified by:
getAllowedMethods
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLength
public int getLength()- Specified by:
getLength
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getEntityTag
public javax.ws.rs.core.EntityTag getEntityTag()- Specified by:
getEntityTag
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLastModified
- Specified by:
getLastModified
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLocation
- Specified by:
getLocation
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLinks
- Specified by:
getLinks
in interfacejavax.ws.rs.container.ContainerResponseContext
-
hasLink
- Specified by:
hasLink
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLink
- Specified by:
getLink
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getLinkBuilder
- Specified by:
getLinkBuilder
in interfacejavax.ws.rs.container.ContainerResponseContext
-
hasEntity
public boolean hasEntity()- Specified by:
hasEntity
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getEntity
- Specified by:
getEntity
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setEntity
Set a new message message entity.- Specified by:
setEntity
in interfacejavax.ws.rs.container.ContainerResponseContext
- Parameters:
entity
- entity object.- See Also:
-
setEntity
Set a new message message entity.- Parameters:
entity
- entity object.annotations
- annotations attached to the entity.- See Also:
-
setEntity
Set a new message message entity.- Parameters:
entity
- entity object.type
- declared entity class.annotations
- annotations attached to the entity.- See Also:
-
setEntity
public void setEntity(Object entity, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) - Specified by:
setEntity
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setMediaType
public void setMediaType(javax.ws.rs.core.MediaType mediaType) Set the message content media type.- Parameters:
mediaType
- message content media type.
-
getEntityClass
- Specified by:
getEntityClass
in interfacejavax.ws.rs.container.ContainerResponseContext
-
getEntityType
- Specified by:
getEntityType
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setEntityType
Set the message entity type information. This method overrides any computed or previously set entity type information.- Parameters:
type
- overriding message entity type.
-
getEntityAnnotations
- Specified by:
getEntityAnnotations
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setEntityAnnotations
Set the annotations attached to the entity.- Parameters:
annotations
- entity annotations.
-
getEntityStream
- Specified by:
getEntityStream
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setEntityStream
- Specified by:
setEntityStream
in interfacejavax.ws.rs.container.ContainerResponseContext
-
setStreamProvider
Set the output stream provider callback. This method must be called before first bytes are written to theentity stream
.- Parameters:
streamProvider
- non-null
output stream provider.
-
enableBuffering
public void enableBuffering(javax.ws.rs.core.Configuration configuration) Enable a buffering of serialized entity. The buffering will be configured from configuration. The property determining the size of the buffer isCommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER
. The buffering functionality is by default disabled and could be enabled by calling this method. In this case this method must be called before first bytes are written to theentity stream
.- Parameters:
configuration
- runtime configuration.
-
commitStream
Commit theentity stream
unless already committed.- Throws:
IOException
- in case of the IO error.
-
isCommitted
public boolean isCommitted()Returnstrue
if the entity stream has been committed.- Returns:
true
if the entity stream has been committed. Otherwise returnsfalse
.
-
close
public void close()Closes the response. Flushes and closes the entity stream, frees up container resources associated with the corresponding request. -
isChunked
public boolean isChunked()Returnstrue
if the response entity is aChunkedOutput
instance.- Returns:
true
if the entity is aChunkedOutput
instance,false
otherwise.
-