Package org.glassfish.jersey.server
Class ContainerResponse
java.lang.Object
org.glassfish.jersey.server.ContainerResponse
- All Implemented Interfaces:
ContainerResponseContext
Jersey container response context.
- Author:
- Marek Potociar
-
Constructor Summary
ConstructorDescriptionContainerResponse
(ContainerRequest requestContext, Response 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
(Configuration configuration) Enable a buffering of serialized entity.getDate()
Class<?>
getHeaderString
(String name) int
getLinkBuilder
(String relation) getLinks()
Get the associated container request context paired with this response context.int
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, 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
(MediaType mediaType) Set the message content media type.void
setStatus
(int code) void
setStatusInfo
(Response.StatusType status) void
setStreamProvider
(OutboundMessageContext.StreamProvider streamProvider) Set the output stream provider callback.
-
Constructor Details
-
ContainerResponse
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 interfaceContainerResponseContext
-
setStatus
public void setStatus(int code) - Specified by:
setStatus
in interfaceContainerResponseContext
-
setStatusInfo
- Specified by:
setStatusInfo
in interfaceContainerResponseContext
-
getStatusInfo
- Specified by:
getStatusInfo
in interfaceContainerResponseContext
-
getRequestContext
Get the associated container request context paired with this response context.- Returns:
- associated container request context.
-
getCookies
- Specified by:
getCookies
in interfaceContainerResponseContext
-
getWrappedMessageContext
Get the wrapped response message context.- Returns:
- wrapped response message context.
-
getHeaderString
- Specified by:
getHeaderString
in interfaceContainerResponseContext
-
getHeaders
- Specified by:
getHeaders
in interfaceContainerResponseContext
-
getStringHeaders
- Specified by:
getStringHeaders
in interfaceContainerResponseContext
-
getDate
- Specified by:
getDate
in interfaceContainerResponseContext
-
getLanguage
- Specified by:
getLanguage
in interfaceContainerResponseContext
-
getMediaType
- Specified by:
getMediaType
in interfaceContainerResponseContext
-
getAllowedMethods
- Specified by:
getAllowedMethods
in interfaceContainerResponseContext
-
getLength
public int getLength()- Specified by:
getLength
in interfaceContainerResponseContext
-
getEntityTag
- Specified by:
getEntityTag
in interfaceContainerResponseContext
-
getLastModified
- Specified by:
getLastModified
in interfaceContainerResponseContext
-
getLocation
- Specified by:
getLocation
in interfaceContainerResponseContext
-
getLinks
- Specified by:
getLinks
in interfaceContainerResponseContext
-
hasLink
- Specified by:
hasLink
in interfaceContainerResponseContext
-
getLink
- Specified by:
getLink
in interfaceContainerResponseContext
-
getLinkBuilder
- Specified by:
getLinkBuilder
in interfaceContainerResponseContext
-
hasEntity
public boolean hasEntity()- Specified by:
hasEntity
in interfaceContainerResponseContext
-
getEntity
- Specified by:
getEntity
in interfaceContainerResponseContext
-
setEntity
Set a new message message entity.- Specified by:
setEntity
in interfaceContainerResponseContext
- 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
- Specified by:
setEntity
in interfaceContainerResponseContext
-
setMediaType
Set the message content media type.- Parameters:
mediaType
- message content media type.
-
getEntityClass
- Specified by:
getEntityClass
in interfaceContainerResponseContext
-
getEntityType
- Specified by:
getEntityType
in interfaceContainerResponseContext
-
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 interfaceContainerResponseContext
-
setEntityAnnotations
Set the annotations attached to the entity.- Parameters:
annotations
- entity annotations.
-
getEntityStream
- Specified by:
getEntityStream
in interfaceContainerResponseContext
-
setEntityStream
- Specified by:
setEntityStream
in interfaceContainerResponseContext
-
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
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.
-