org.jboss.resteasy.client.core
Class ClientResponseImpl<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.ClientResponseImpl<T>

public class ClientResponseImpl<T>
extends ClientResponse<T>

Version:
$Revision: 1 $
Author:
Bill Burke

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.ws.rs.core.Response
Response.ResponseBuilder, Response.Status
 
Field Summary
protected  boolean allowRereads
           
protected  java.lang.String alternateMediaType
           
protected  java.lang.annotation.Annotation[] annotations
           
protected  java.lang.String attributeExceptionsTo
           
protected  org.apache.commons.httpclient.HttpMethodBase baseMethod
           
protected  boolean cacheInputStream
           
protected  java.lang.Exception exception
           
protected  java.lang.reflect.Type genericReturnType
           
protected  CaseInsensitiveMap<java.lang.String> headers
           
protected  java.lang.Iterable<ClientInterceptor> interceptors
           
protected  boolean performExecute
           
protected  ResteasyProviderFactory providerFactory
           
protected  byte[] rawResults
           
protected  java.lang.String restVerb
           
protected  java.lang.Class<?> returnType
           
protected  int status
           
protected  boolean streamWasRead
           
protected  java.lang.Object unmarshaledEntity
           
protected  java.lang.String url
           
protected  boolean wasReleased
           
 
Constructor Summary
ClientResponseImpl()
           
 
Method Summary
 void checkFailureStatus()
           
 ClientResponseFailure createResponseFailure(java.lang.String message)
           
 ClientResponseFailure createResponseFailure(java.lang.String message, java.lang.Exception e)
           
 int execute(org.apache.commons.httpclient.HttpClient client)
           
static CaseInsensitiveMap<java.lang.String> extractHeaders(org.apache.commons.httpclient.HttpMethodBase baseMethod)
           
protected  void finalize()
           
 java.lang.annotation.Annotation[] getAnnotations()
           
 java.lang.String getAttributeExceptionsTo()
           
 java.lang.String getContentType()
           
 org.apache.commons.httpclient.Header getContentTypeHeader()
           
 T getEntity()
          Unmarshal the target entity from the response 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(GenericType<T2> genericType)
          Extract the response body with the provided type information.
 java.lang.Exception getException()
           
 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
 org.apache.commons.httpclient.HttpMethodBase getHttpBaseMethod()
           
 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.String getRestVerb()
           
 java.lang.Class<?> getReturnType()
           
 int getStatus()
          Get the status code associated with the response.
 boolean isAllowRereads()
           
 boolean isPerformExecute()
           
 void releaseConnection()
           
 void setAllowRereads(boolean allowRereads)
           
 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 setInterceptors(java.lang.Iterable<ClientInterceptor> interceptors)
           
 void setPerformExecute(boolean performExecute)
           
 void setProviderFactory(ResteasyProviderFactory providerFactory)
           
 void setRestVerb(java.lang.String restVerb)
           
 void setReturnType(java.lang.Class<T> returnType)
           
 void setUrl(java.lang.String url)
           
 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, 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

interceptors

protected java.lang.Iterable<ClientInterceptor> interceptors

restVerb

protected java.lang.String restVerb

url

protected java.lang.String url

baseMethod

protected org.apache.commons.httpclient.HttpMethodBase baseMethod

headers

protected CaseInsensitiveMap<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

rawResults

protected byte[] rawResults

unmarshaledEntity

protected java.lang.Object unmarshaledEntity

exception

protected java.lang.Exception exception

allowRereads

protected boolean allowRereads

performExecute

protected boolean performExecute

cacheInputStream

protected boolean cacheInputStream
Constructor Detail

ClientResponseImpl

public ClientResponseImpl()
Method Detail

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)

setInterceptors

public void setInterceptors(java.lang.Iterable<ClientInterceptor> interceptors)

getContentTypeHeader

public org.apache.commons.httpclient.Header getContentTypeHeader()

getContentType

public java.lang.String getContentType()

getAnnotations

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

getResponseHeader

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

setAlternateMediaType

public void setAlternateMediaType(java.lang.String alternateMediaType)

getHttpBaseMethod

public org.apache.commons.httpclient.HttpMethodBase getHttpBaseMethod()

isAllowRereads

public boolean isAllowRereads()

setAllowRereads

public void setAllowRereads(boolean allowRereads)

isPerformExecute

public boolean isPerformExecute()

setPerformExecute

public void setPerformExecute(boolean performExecute)

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,
                         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(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:

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.

finalize

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

getRestVerb

public java.lang.String getRestVerb()

setRestVerb

public void setRestVerb(java.lang.String restVerb)

setUrl

public void setUrl(java.lang.String url)

execute

public int execute(org.apache.commons.httpclient.HttpClient client)

extractHeaders

public static CaseInsensitiveMap<java.lang.String> extractHeaders(org.apache.commons.httpclient.HttpMethodBase baseMethod)

checkFailureStatus

public void checkFailureStatus()

createResponseFailure

public ClientResponseFailure createResponseFailure(java.lang.String message)

createResponseFailure

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

releaseConnection

public void releaseConnection()

getResponseStatus

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

wasReleased

public boolean wasReleased()


Copyright © 2009. All Rights Reserved.