|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.ws.rs.core.Response
org.jboss.resteasy.client.ClientResponse<T>
org.jboss.resteasy.client.core.BaseClientResponse<T>
public class BaseClientResponse<T>
| Nested Class Summary | |
|---|---|
static interface |
BaseClientResponse.BaseClientResponseStreamFactory
|
| Nested classes/interfaces inherited from class javax.ws.rs.core.Response |
|---|
Response.ResponseBuilder, Response.Status, Response.StatusType |
| Field Summary | |
|---|---|
protected String |
alternateMediaType
|
protected Annotation[] |
annotations
|
protected String |
attributeExceptionsTo
|
protected Map<String,Object> |
attributes
|
protected Exception |
exception
|
protected ClientExecutor |
executor
|
protected Type |
genericReturnType
|
protected MultivaluedMap<String,String> |
headers
|
protected LinkHeader |
linkHeader
|
protected Link |
location
|
protected ResteasyProviderFactory |
providerFactory
|
protected ReaderInterceptor[] |
readerInterceptors
|
protected Class<?> |
returnType
|
protected int |
status
|
protected BaseClientResponse.BaseClientResponseStreamFactory |
streamFactory
|
protected Object |
unmarshaledEntity
|
protected boolean |
wasReleased
|
| Constructor Summary | |
|---|---|
BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
|
|
BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory,
ClientExecutor executor)
|
|
| Method Summary | ||
|---|---|---|
boolean |
bufferEntity()
Buffer the message entity data. |
|
void |
checkFailureStatus()
|
|
void |
close()
Close the underlying message entity input stream (if available and open) as well as releases any other resources associated with the response (e.g. |
|
static ClientResponse |
copyFromError(ClientResponse copy)
Store entity within a byte array input stream because we want to release the connection if a ClientResponseFailure is thrown. |
|
ClientResponseFailure |
createResponseFailure(String message)
|
|
ClientResponseFailure |
createResponseFailure(String message,
Exception e)
|
|
protected void |
finalize()
|
|
Set<String> |
getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header. |
|
Annotation[] |
getAnnotations()
|
|
String |
getAttributeExceptionsTo()
|
|
Map<String,Object> |
getAttributes()
Used to pass information to and between interceptors. |
|
Map<String,NewCookie> |
getCookies()
Get any new cookies set on the response message. |
|
Date |
getDate()
Get message date. |
|
T |
getEntity()
Unmarshal the target entity from the response OutputStream. |
|
|
getEntity(Class<T2> type)
Extract the response body with the provided type information This method actually does the reading on the OutputStream. |
|
|
getEntity(Class<T2> type,
Type genericType)
Extract the response body with the provided type information This method actually does the reading on the OutputStream. |
|
|
getEntity(Class<T2> type,
Type genericType,
Annotation[] anns)
|
|
|
getEntity(GenericType<T2> genericType)
Extract the response body with the provided type information. |
|
|
getEntity(GenericType<T2> genericType,
Annotation[] ann)
|
|
EntityTag |
getEntityTag()
Get the entity tag. |
|
Exception |
getException()
|
|
Link |
getHeaderAsLink(String headerName)
Header is assumed to be a URL, a Link object is created from it if it exists. |
|
String |
getHeaderString(String name)
Get a message header as a single string value. |
|
Locale |
getLanguage()
Get the language of the message entity. |
|
Date |
getLastModified()
Get the last modified date. |
|
int |
getLength()
Get Content-Length value. |
|
Link |
getLink(String relation)
Get the link for the relation. |
|
Link.Builder |
getLinkBuilder(String relation)
Convenience method that returns a Link.Builder for the relation. |
|
LinkHeader |
getLinkHeader()
Get the link headers of the response. |
|
Set<Link> |
getLinks()
Get the links attached to the message as headers. |
|
URI |
getLocation()
Get the location. |
|
Link |
getLocationLink()
Get the Location header as a Link so you can easily execute on it. |
|
MediaType |
getMediaType()
Get the media type of the message entity. |
|
MultivaluedMap<String,Object> |
getMetadata()
See Response.getHeaders(). |
|
String |
getResponseHeader(String headerKey)
|
|
MultivaluedMap<String,String> |
getResponseHeaders()
This method returns the same exact map as Response.getMetadata() except as a map of strings rather than objects |
|
Response.Status |
getResponseStatus()
|
|
Class<?> |
getReturnType()
|
|
int |
getStatus()
Get the status code associated with the response. |
|
Response.StatusType |
getStatusInfo()
Get the complete status information associated with the response. |
|
BaseClientResponse.BaseClientResponseStreamFactory |
getStreamFactory()
|
|
MultivaluedMap<String,String> |
getStringHeaders()
Get view of the response headers and their string values. |
|
boolean |
hasEntity()
Check if there is an entity available in the response. |
|
boolean |
hasLink(String relation)
Check if link for relation exists. |
|
|
readEntity(Class<T> entityType)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(Class<T> entityType,
Annotation[] annotations)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(GenericType<T> entityType)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(GenericType<T> entityType,
Annotation[] annotations)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
protected
|
readFrom(Class<T2> type,
Type genericType,
MediaType media,
Annotation[] annotations)
|
|
void |
releaseConnection()
|
|
void |
resetStream()
Attempts to reset the InputStream of the response. |
|
void |
setAlternateMediaType(String alternateMediaType)
|
|
void |
setAnnotations(Annotation[] annotations)
|
|
void |
setAttributeExceptionsTo(String attributeExceptionsTo)
|
|
void |
setAttributes(Map<String,Object> attributes)
|
|
void |
setException(Exception exception)
|
|
void |
setGenericReturnType(Type genericReturnType)
|
|
void |
setHeaders(MultivaluedMap<String,String> headers)
|
|
void |
setProviderFactory(ResteasyProviderFactory providerFactory)
|
|
void |
setReaderInterceptors(ReaderInterceptor[] readerInterceptors)
|
|
void |
setReturnType(Class<T> returnType)
|
|
void |
setStatus(int status)
|
|
void |
setStreamFactory(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
|
|
boolean |
wasReleased()
|
|
| Methods inherited from class javax.ws.rs.core.Response |
|---|
accepted, accepted, created, fromResponse, getHeaders, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, temporaryRedirect |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ResteasyProviderFactory providerFactory
protected String attributeExceptionsTo
protected MultivaluedMap<String,String> headers
protected String alternateMediaType
protected Class<?> returnType
protected Type genericReturnType
protected Annotation[] annotations
protected int status
protected boolean wasReleased
protected Object unmarshaledEntity
protected ReaderInterceptor[] readerInterceptors
protected Exception exception
protected BaseClientResponse.BaseClientResponseStreamFactory streamFactory
protected LinkHeader linkHeader
protected Link location
protected ClientExecutor executor
protected Map<String,Object> attributes
| Constructor Detail |
|---|
public BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory,
ClientExecutor executor)
public BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
| Method Detail |
|---|
public static ClientResponse copyFromError(ClientResponse copy)
copy -
public Map<String,Object> getAttributes()
ClientResponse
getAttributes in class ClientResponse<T>public void setAttributes(Map<String,Object> attributes)
public void setReaderInterceptors(ReaderInterceptor[] readerInterceptors)
public void setStatus(int status)
public void setHeaders(MultivaluedMap<String,String> headers)
public void setProviderFactory(ResteasyProviderFactory providerFactory)
public void setReturnType(Class<T> returnType)
public Class<?> getReturnType()
public void setGenericReturnType(Type genericReturnType)
public void setAnnotations(Annotation[] annotations)
public String getAttributeExceptionsTo()
public void setAttributeExceptionsTo(String attributeExceptionsTo)
public Exception getException()
public void setException(Exception exception)
public Annotation[] getAnnotations()
public String getResponseHeader(String headerKey)
public LinkHeader getLinkHeader()
ClientResponse
getLinkHeader in class ClientResponse<T>public Link getLocationLink()
ClientResponse
getLocationLink in class ClientResponse<T>public Link getHeaderAsLink(String headerName)
ClientResponse
getHeaderAsLink in class ClientResponse<T>public void setAlternateMediaType(String alternateMediaType)
public BaseClientResponse.BaseClientResponseStreamFactory getStreamFactory()
public void setStreamFactory(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
public void resetStream()
ClientResponse
resetStream in class ClientResponse<T>public T getEntity()
ClientResponse
getEntity in class ClientResponse<T>null if message does not contain an
entity body.public <T2> T2 getEntity(Class<T2> type)
ClientResponse
getEntity in class ClientResponse<T>
public <T2> T2 getEntity(Class<T2> type,
Type genericType)
ClientResponse
getEntity in class ClientResponse<T>
public <T2> T2 getEntity(Class<T2> type,
Type genericType,
Annotation[] anns)
getEntity in class ClientResponse<T>public MediaType getMediaType()
Response
getMediaType in class Responsenull if there is no response entity.
protected <T2> Object readFrom(Class<T2> type,
Type genericType,
MediaType media,
Annotation[] annotations)
public <T2> T2 getEntity(GenericType<T2> genericType)
ClientResponseListlist = response.getEntity(new GenericType () {}); This method actually does the reading on the OutputStream. It will only do the read once. Afterwards, it will cache the result and return the cached result.
- Specified by:
getEntityin classClientResponse<T>
- Returns:
public <T2> T2 getEntity(GenericType<T2> genericType,
Annotation[] ann)
getEntity in class ClientResponse<T>public MultivaluedMap<String,String> getResponseHeaders()
ClientResponse
getResponseHeaders in class ClientResponse<T>public MultivaluedMap<String,Object> getMetadata()
ResponseResponse.getHeaders().
This method is considered deprecated. Users are encouraged to switch their
code to use the getHeaders() method instead. The method may be annotated
as @Deprecated in a future release of JAX-RS API.
getMetadata in class Responsepublic int getStatus()
Response
getStatus in class Responsepublic Response.StatusType getStatusInfo()
Response
getStatusInfo in class Responsenull.public void checkFailureStatus()
public ClientResponseFailure createResponseFailure(String message)
public ClientResponseFailure createResponseFailure(String message,
Exception e)
public Response.Status getResponseStatus()
getResponseStatus in class ClientResponse<T>public boolean wasReleased()
public final void releaseConnection()
releaseConnection in class ClientResponse<T>
protected final void finalize()
throws Throwable
finalize in class ObjectThrowablepublic <T> T readEntity(Class<T> entityType)
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an ProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the original entity input stream has already been consumed
without buffering the entity data prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the an unconsumed original response entity data stream
if open. In case the entity data has been buffered, the buffer will be reset
prior consuming the buffered data to enable subsequent invocations of
readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity.
null
or a corresponding Java object that represents zero-length data.MessageBodyReaderpublic <T> T readEntity(GenericType<T> entityType)
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an ProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the original entity input stream has already been consumed
without buffering the entity data prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the an unconsumed original response entity data stream
if open. In case the entity data has been buffered, the buffer will be reset
prior consuming the buffered data to enable subsequent invocations of
readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity; may be generic.
null
or a corresponding Java object that represents zero-length data.MessageBodyReader
public <T> T readEntity(Class<T> entityType,
Annotation[] annotations)
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an ProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the original entity input stream has already been consumed
without buffering the entity data prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the an unconsumed original response entity data stream
if open. In case the entity data has been buffered, the buffer will be reset
prior consuming the buffered data to enable subsequent invocations of
readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity.annotations - annotations that will be passed to the MessageBodyReader.
null
or a corresponding Java object that represents zero-length data.MessageBodyReader
public <T> T readEntity(GenericType<T> entityType,
Annotation[] annotations)
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an ProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the original entity input stream has already been consumed
without buffering the entity data prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the an unconsumed original response entity data stream
if open. In case the entity data has been buffered, the buffer will be reset
prior consuming the buffered data to enable subsequent invocations of
readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity; may be generic.annotations - annotations that will be passed to the MessageBodyReader.
null
or a corresponding Java object that represents zero-length data.MessageBodyReaderpublic boolean hasEntity()
Responsetrue if the entity is present, returns false otherwise.
hasEntity in class Responsetrue if there is an entity present in the message,
false otherwise.public boolean bufferEntity()
Response
In case the message entity is backed by an unconsumed entity input stream,
all the bytes of the original entity input stream are read and stored in a
local buffer. The original entity input stream is consumed and automatically
closed as part of the operation and the method returns true.
In case the response entity instance is not backed by an unconsumed input stream
an invocation of bufferEntity method is ignored and the method returns
false.
This operation is idempotent, i.e. it can be invoked multiple times with
the same effect which also means that calling the bufferEntity()
method on an already buffered (and thus closed) message instance is legal
and has no further effect. Also, the result returned by the bufferEntity()
method is consistent across all invocations of the method on the same
Response instance.
Buffering the message entity data allows for multiple invocations of
readEntity(...) methods on the response instance. Note however, that
once the response instance itself is closed, the implementations
are expected to release the buffered message entity data too. Therefore any subsequent
attempts to read a message entity stream on such closed response will result in an
IllegalStateException being thrown.
bufferEntity in class Responsetrue if the message entity input stream was available and
was buffered successfully, returns false if the entity stream
was not available.public void close()
Responsebuffered message entity data).
This operation is idempotent, i.e. it can be invoked multiple times with the
same effect which also means that calling the close() method on an
already closed message instance is legal and has no further effect.
The close() method should be invoked on all instances that
contain an un-consumed entity input stream to ensure the resources associated
with the instance are properly cleaned-up and prevent potential memory leaks.
This is typical for client-side scenarios where application layer code
processes only the response headers and ignores the response entity.
Any attempts to manipulate (read, get, buffer) a message entity on a closed response
will result in an IllegalStateException being thrown.
close in class Responsepublic String getHeaderString(String name)
ResponseRuntimeDelegate.HeaderDelegate if one is available
via RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the header value class or using its toString method if a header
delegate is not available.
getHeaderString in class Responsename - the message header.
null is returned. If the message header is present but has no
value then the empty string is returned. If the message header is present
more than once then the values of joined together and separated by a ','
character.Response.getHeaders(),
Response.getStringHeaders()public Locale getLanguage()
Response
getLanguage in class Responsepublic int getLength()
Response
getLength in class Response-1.public Map<String,NewCookie> getCookies()
Response
getCookies in class Responsepublic EntityTag getEntityTag()
Response
getEntityTag in class Responsenull if not present.public Date getDate()
Response
getDate in class Responsenull if not present.public Date getLastModified()
Response
getLastModified in class Responsenull if not present.public Set<Link> getLinks()
Response
getLinks in class ResponseSet if no links are present. Does
not return null.public boolean hasLink(String relation)
Response
hasLink in class Responserelation - link relation.
true if the link for the relation is present in the
message headers, false otherwise.public Link getLink(String relation)
Response
getLink in class Responserelation - link relation.
null if not present.public Link.Builder getLinkBuilder(String relation)
ResponseLink.Builder for the relation.
See Response.getLink(java.lang.String) for more information.
getLinkBuilder in class Responserelation - link relation.
null if not
present.public URI getLocation()
Response
getLocation in class Responsenull if not present.public Set<String> getAllowedMethods()
Response
getAllowedMethods in class Responsepublic MultivaluedMap<String,String> getStringHeaders()
Response
getStringHeaders in class ResponseResponse.getHeaders(),
Response.getHeaderString(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||