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
ConstructorsConstructorDescriptionContainerResponse(ContainerRequest requestContext, Response response) Create a new Jersey container response context. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the response.voidCommit theentity streamunless already committed.voidenableBuffering(Configuration configuration) Enable a buffering of serialized entity.getDate()Class<?>getHeaderString(String name) intgetLinkBuilder(String relation) getLinks()Get the associated container request context paired with this response context.intGet the wrapped response message context.booleanbooleanbooleanReturnstrueif the response entity is aChunkedOutputinstance.booleanReturnstrueif the entity stream has been committed.booleanReturns true if the response is result of the exception (for example created duringexception mapping).voidSet a new message message entity.voidsetEntity(Object entity, Annotation[] annotations) Set a new message message entity.voidsetEntity(Object entity, Annotation[] annotations, MediaType mediaType) voidsetEntity(Object entity, Type type, Annotation[] annotations) Set a new message message entity.voidsetEntityAnnotations(Annotation[] annotations) Set the annotations attached to the entity.voidsetEntityStream(OutputStream outputStream) voidsetEntityType(Type type) Set the message entity type information.voidsetMappedFromException(boolean mappedFromException) Sets the flag indicating whether the response was created based on the exception.voidsetMediaType(MediaType mediaType) Set the message content media type.voidsetStatus(int code) voidsetStatusInfo(Response.StatusType status) voidsetStreamProvider(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:
getStatusin interfaceContainerResponseContext
-
setStatus
public void setStatus(int code) - Specified by:
setStatusin interfaceContainerResponseContext
-
setStatusInfo
- Specified by:
setStatusInfoin interfaceContainerResponseContext
-
getStatusInfo
- Specified by:
getStatusInfoin interfaceContainerResponseContext
-
getRequestContext
Get the associated container request context paired with this response context.- Returns:
- associated container request context.
-
getCookies
- Specified by:
getCookiesin interfaceContainerResponseContext
-
getWrappedMessageContext
Get the wrapped response message context.- Returns:
- wrapped response message context.
-
getHeaderString
- Specified by:
getHeaderStringin interfaceContainerResponseContext
-
getHeaders
- Specified by:
getHeadersin interfaceContainerResponseContext
-
getStringHeaders
- Specified by:
getStringHeadersin interfaceContainerResponseContext
-
getDate
- Specified by:
getDatein interfaceContainerResponseContext
-
getLanguage
- Specified by:
getLanguagein interfaceContainerResponseContext
-
getMediaType
- Specified by:
getMediaTypein interfaceContainerResponseContext
-
getAllowedMethods
- Specified by:
getAllowedMethodsin interfaceContainerResponseContext
-
getLength
public int getLength()- Specified by:
getLengthin interfaceContainerResponseContext
-
getEntityTag
- Specified by:
getEntityTagin interfaceContainerResponseContext
-
getLastModified
- Specified by:
getLastModifiedin interfaceContainerResponseContext
-
getLocation
- Specified by:
getLocationin interfaceContainerResponseContext
-
getLinks
- Specified by:
getLinksin interfaceContainerResponseContext
-
hasLink
- Specified by:
hasLinkin interfaceContainerResponseContext
-
getLink
- Specified by:
getLinkin interfaceContainerResponseContext
-
getLinkBuilder
- Specified by:
getLinkBuilderin interfaceContainerResponseContext
-
hasEntity
public boolean hasEntity()- Specified by:
hasEntityin interfaceContainerResponseContext
-
getEntity
- Specified by:
getEntityin interfaceContainerResponseContext
-
setEntity
Set a new message message entity.- Specified by:
setEntityin 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:
setEntityin interfaceContainerResponseContext
-
setMediaType
Set the message content media type.- Parameters:
mediaType- message content media type.
-
getEntityClass
- Specified by:
getEntityClassin interfaceContainerResponseContext
-
getEntityType
- Specified by:
getEntityTypein 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:
getEntityAnnotationsin interfaceContainerResponseContext
-
setEntityAnnotations
Set the annotations attached to the entity.- Parameters:
annotations- entity annotations.
-
getEntityStream
- Specified by:
getEntityStreamin interfaceContainerResponseContext
-
setEntityStream
- Specified by:
setEntityStreamin interfaceContainerResponseContext
-
setStreamProvider
Set the output stream provider callback. This method must be called before first bytes are written to theentity stream.- Parameters:
streamProvider- non-nulloutput 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 streamunless already committed.- Throws:
IOException- in case of the IO error.
-
isCommitted
public boolean isCommitted()Returnstrueif the entity stream has been committed.- Returns:
trueif 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()Returnstrueif the response entity is aChunkedOutputinstance.- Returns:
trueif the entity is aChunkedOutputinstance,falseotherwise.
-