org.jboss.resteasy.client.core
Class BaseClientResponse<T>

java.lang.Object
  extended by javax.ws.rs.core.Response
      extended by org.jboss.resteasy.client.ClientResponse<T>
          extended by org.jboss.resteasy.client.core.BaseClientResponse<T>

public class BaseClientResponse<T>
extends ClientResponse<T>

Version:
$Revision: 1 $
Author:
Bill Burke

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  java.lang.String alternateMediaType
           
protected  java.lang.annotation.Annotation[] annotations
           
protected  java.lang.String attributeExceptionsTo
           
protected  boolean cacheInputStream
           
protected  java.lang.Exception exception
           
protected  ClientExecutor executor
           
protected  java.lang.reflect.Type genericReturnType
           
protected  MultivaluedMap<java.lang.String,java.lang.String> headers
           
protected  LinkHeader linkHeader
           
protected  Link location
           
protected  MessageBodyReaderInterceptor[] messageBodyReaderInterceptors
           
protected  ResteasyProviderFactory providerFactory
           
protected  java.lang.Class<?> returnType
           
protected  int status
           
protected  BaseClientResponse.BaseClientResponseStreamFactory streamFactory
           
protected  boolean streamWasRead
           
protected  java.lang.Object unmarshaledEntity
           
protected  boolean wasReleased
           
 
Constructor Summary
BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
           
BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory, ClientExecutor executor)
           
 
Method Summary
 void checkFailureStatus()
           
 ClientResponseFailure createResponseFailure(java.lang.String message)
           
 ClientResponseFailure createResponseFailure(java.lang.String message, java.lang.Exception e)
           
protected  void finalize()
           
 java.lang.annotation.Annotation[] getAnnotations()
           
 java.lang.String getAttributeExceptionsTo()
           
 T getEntity()
          Unmarshal the target entity from the response OutputStream.
<T2> T2
getEntity(java.lang.Class<T2> type)
          Extract the response body with the provided type information

This method actually does the reading on the OutputStream.

<T2> T2
getEntity(java.lang.Class<T2> type, java.lang.reflect.Type genericType)
          Extract the response body with the provided type information

This method actually does the reading on the OutputStream.

<T2> T2
getEntity(java.lang.Class<T2> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] anns)
           
<T2> T2
getEntity(GenericType<T2> genericType)
          Extract the response body with the provided type information.
<T2> T2
getEntity(GenericType<T2> genericType, java.lang.annotation.Annotation[] ann)
           
 java.lang.Exception getException()
           
 Link getHeaderAsLink(java.lang.String headerName)
          Header is assumed to be a URL, a Link object is created from it if it exists.
 MultivaluedMap<java.lang.String,java.lang.String> getHeaders()
          This method returns the same exact map as Response.getMetadata() except as a map of strings rather than objects
 LinkHeader getLinkHeader()
          Get the link headers of the response.
 Link getLocation()
          Get the Location header as a Link so you can easily execute on it.
protected  MediaType getMediaType()
           
 MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
          Get metadata associated with the response as a map.
 java.lang.String getResponseHeader(java.lang.String headerKey)
           
 Response.Status getResponseStatus()
           
 java.lang.Class<?> getReturnType()
           
 int getStatus()
          Get the status code associated with the response.
 BaseClientResponse.BaseClientResponseStreamFactory getStreamFactory()
           
protected
<T2> java.lang.Object
readFrom(java.lang.Class<T2> type, java.lang.reflect.Type genericType, MediaType media, java.lang.annotation.Annotation[] annotations)
           
 void releaseConnection()
           
 void setAlternateMediaType(java.lang.String alternateMediaType)
           
 void setAnnotations(java.lang.annotation.Annotation[] annotations)
           
 void setAttributeExceptionsTo(java.lang.String attributeExceptionsTo)
           
 void setException(java.lang.Exception exception)
           
 void setGenericReturnType(java.lang.reflect.Type genericReturnType)
           
 void setHeaders(MultivaluedMap<java.lang.String,java.lang.String> headers)
           
 void setMessageBodyReaderInterceptors(MessageBodyReaderInterceptor[] messageBodyReaderInterceptors)
           
 void setProviderFactory(ResteasyProviderFactory providerFactory)
           
 void setReturnType(java.lang.Class<T> returnType)
           
 void setStatus(int status)
           
 void setStreamFactory(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
           
 boolean wasReleased()
           
 
Methods inherited from class javax.ws.rs.core.Response
created, fromResponse, 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

providerFactory

protected ResteasyProviderFactory providerFactory

attributeExceptionsTo

protected java.lang.String attributeExceptionsTo

headers

protected MultivaluedMap<java.lang.String,java.lang.String> headers

alternateMediaType

protected java.lang.String alternateMediaType

returnType

protected java.lang.Class<?> returnType

genericReturnType

protected java.lang.reflect.Type genericReturnType

annotations

protected java.lang.annotation.Annotation[] annotations

status

protected int status

wasReleased

protected boolean wasReleased

streamWasRead

protected boolean streamWasRead

unmarshaledEntity

protected java.lang.Object unmarshaledEntity

messageBodyReaderInterceptors

protected MessageBodyReaderInterceptor[] messageBodyReaderInterceptors

exception

protected java.lang.Exception exception

cacheInputStream

protected boolean cacheInputStream

streamFactory

protected BaseClientResponse.BaseClientResponseStreamFactory streamFactory

linkHeader

protected LinkHeader linkHeader

location

protected Link location

executor

protected ClientExecutor executor
Constructor Detail

BaseClientResponse

public BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory,
                          ClientExecutor executor)

BaseClientResponse

public BaseClientResponse(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)
Method Detail

setMessageBodyReaderInterceptors

public void setMessageBodyReaderInterceptors(MessageBodyReaderInterceptor[] messageBodyReaderInterceptors)

setStatus

public void setStatus(int status)

setHeaders

public void setHeaders(MultivaluedMap<java.lang.String,java.lang.String> headers)

setProviderFactory

public void setProviderFactory(ResteasyProviderFactory providerFactory)

setReturnType

public void setReturnType(java.lang.Class<T> returnType)

getReturnType

public java.lang.Class<?> getReturnType()

setGenericReturnType

public void setGenericReturnType(java.lang.reflect.Type genericReturnType)

setAnnotations

public void setAnnotations(java.lang.annotation.Annotation[] annotations)

getAttributeExceptionsTo

public java.lang.String getAttributeExceptionsTo()

setAttributeExceptionsTo

public void setAttributeExceptionsTo(java.lang.String attributeExceptionsTo)

getException

public java.lang.Exception getException()

setException

public void setException(java.lang.Exception exception)

getAnnotations

public java.lang.annotation.Annotation[] getAnnotations()

getResponseHeader

public java.lang.String getResponseHeader(java.lang.String headerKey)

getLinkHeader

public LinkHeader getLinkHeader()
Description copied from class: ClientResponse
Get the link headers of the response. All Link objects returned will automatically have the same ClientExecutor as the request.

Specified by:
getLinkHeader in class ClientResponse<T>
Returns:
non-null

getLocation

public Link getLocation()
Description copied from class: ClientResponse
Get the Location header as a Link so you can easily execute on it. All Link objects returned will automatically have the same ClientExecutor as the request.

Specified by:
getLocation in class ClientResponse<T>
Returns:

getHeaderAsLink

public Link getHeaderAsLink(java.lang.String headerName)
Description copied from class: ClientResponse
Header is assumed to be a URL, a Link object is created from it if it exists. Also, the type field of the link with be initialized if there is another header appended with -Type. i.e. if the header was "custom" it will also look for a header of custom-type and expect that this is a media type.

All Link objects returned will automatically have the same ClientExecutor as the request.

Specified by:
getHeaderAsLink in class ClientResponse<T>
Returns:
null if it doesn't exist

setAlternateMediaType

public void setAlternateMediaType(java.lang.String alternateMediaType)

getStreamFactory

public BaseClientResponse.BaseClientResponseStreamFactory getStreamFactory()

setStreamFactory

public void setStreamFactory(BaseClientResponse.BaseClientResponseStreamFactory streamFactory)

getEntity

public T getEntity()
Description copied from class: ClientResponse
Unmarshal the target entity from the response OutputStream. You must have type information set via otherwise, this will not work.

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:
getEntity in class ClientResponse<T>
Returns:
an object instance or null if there is no entity
See Also:
MessageBodyWriter

getEntity

public <T2> T2 getEntity(java.lang.Class<T2> type)
Description copied from class: ClientResponse
Extract the response body with the provided type information

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:
getEntity in class ClientResponse<T>
Returns:

getEntity

public <T2> T2 getEntity(java.lang.Class<T2> type,
                         java.lang.reflect.Type genericType)
Description copied from class: ClientResponse
Extract the response body with the provided type information

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:
getEntity in class ClientResponse<T>
Returns:

getEntity

public <T2> T2 getEntity(java.lang.Class<T2> type,
                         java.lang.reflect.Type genericType,
                         java.lang.annotation.Annotation[] anns)
Specified by:
getEntity in class ClientResponse<T>
Returns:

getMediaType

protected MediaType getMediaType()

readFrom

protected <T2> java.lang.Object readFrom(java.lang.Class<T2> type,
                                         java.lang.reflect.Type genericType,
                                         MediaType media,
                                         java.lang.annotation.Annotation[] annotations)

getEntity

public <T2> T2 getEntity(GenericType<T2> genericType)
Description copied from class: ClientResponse
Extract the response body with the provided type information. GenericType is a trick used to pass in generic type information to the resteasy runtime.

For example:

 List list = 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:
getEntity in class ClientResponse<T>
Returns:

getEntity

public <T2> T2 getEntity(GenericType<T2> genericType,
                         java.lang.annotation.Annotation[] ann)
Specified by:
getEntity in class ClientResponse<T>
Returns:

getHeaders

public MultivaluedMap<java.lang.String,java.lang.String> getHeaders()
Description copied from class: ClientResponse
This method returns the same exact map as Response.getMetadata() except as a map of strings rather than objects

Specified by:
getHeaders in class ClientResponse<T>
Returns:

getMetadata

public MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
Description copied from class: Response
Get metadata associated with the response as a map. The returned map may be subsequently modified by the JAX-RS runtime. Values will be serialized using a RuntimeDelegate.HeaderDelegate if one is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the class of the value or using the values toString method if a header delegate is not available.

Specified by:
getMetadata in class Response
Returns:
response metadata as a map

getStatus

public int getStatus()
Description copied from class: Response
Get the status code associated with the response.

Specified by:
getStatus in class Response
Returns:
the response status code or -1 if the status was not set.

checkFailureStatus

public void checkFailureStatus()

createResponseFailure

public ClientResponseFailure createResponseFailure(java.lang.String message)

createResponseFailure

public ClientResponseFailure createResponseFailure(java.lang.String message,
                                                   java.lang.Exception e)

getResponseStatus

public Response.Status getResponseStatus()
Specified by:
getResponseStatus in class ClientResponse<T>

wasReleased

public boolean wasReleased()

releaseConnection

public final void releaseConnection()
Specified by:
releaseConnection in class ClientResponse<T>

finalize

protected final void finalize()
                       throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Copyright © 2010. All Rights Reserved.