org.jboss.resteasy.client.jaxrs.internal

## Class ClientInvocation

- java.lang.Object
- - org.jboss.resteasy.client.jaxrs.internal.ClientInvocation

- All Implemented Interfaces:
    Invocation

      public class ClientInvocation
      extends Object
      implements Invocation

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface javax.ws.rs.client.Invocation

      `Invocation.Builder`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ResteasyClient` | `client`
    `protected ClientConfiguration` | `configuration`
    `protected DelegatingOutputStream` | `delegatingOutputStream`
    `protected Object` | `entity`
    `protected Annotation[]` | `entityAnnotations`
    `protected Class` | `entityClass`
    `protected Type` | `entityGenericType`
    `protected OutputStream` | `entityStream`
    `protected ClientRequestHeaders` | `headers`
    `protected String` | `method`
    `protected URI` | `uri`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientInvocation(ResteasyClient client, URI uri, ClientRequestHeaders headers, ClientConfiguration parent)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `extractResult(GenericType<T> responseType, Response response, Annotation[] annotations)` Extracts result from response throwing an appropriate exception if not a successful response.
    `ResteasyClient` | `getClient()`
    `ClientConfiguration` | `getClientConfiguration()`
    `Configuration` | `getConfiguration()`
    `DelegatingOutputStream` | `getDelegatingOutputStream()`
    `Object` | `getEntity()`
    `Annotation[]` | `getEntityAnnotations()`
    `Class` | `getEntityClass()`
    `Type` | `getEntityGenericType()`
    `OutputStream` | `getEntityStream()`
    `ClientRequestHeaders` | `getHeaders()`
    `String` | `getMethod()`
    `Map<String,Object>` | `getMutableProperties()`
    `ClientRequestFilter[]` | `getRequestFilters()`
    `ClientResponseFilter[]` | `getResponseFilters()`
    `URI` | `getUri()`
    `WriterInterceptor[]` | `getWriterInterceptors()`
    `static <T> T` | `handleErrorStatus(Response response)` Throw an exception.
    `Response` | `invoke()` Synchronously invoke the request and receive a response back.
    `<T> T` | `invoke(Class<T> responseType)` Synchronously invoke the request and receive a response of the specified type back.
    `<T> T` | `invoke(GenericType<T> responseType)` Synchronously invoke the request and receive a response of the specified generic type back.
    `Invocation` | `property(String name, Object value)` Set a new property in the context of a request represented by this invocation.
    `void` | `setDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream)`
    `void` | `setEntity(Entity entity)`
    `void` | `setEntityAnnotations(Annotation[] entityAnnotations)`
    `void` | `setEntityObject(Object ent)`
    `void` | `setEntityStream(OutputStream entityStream)`
    `void` | `setHeaders(ClientRequestHeaders headers)`
    `void` | `setMethod(String method)`
    `void` | `setUri(URI uri)`
    `Future<Response>` | `submit()` Submit the request for an asynchronous invocation and receive a future response back.
    `<T> Future<T>` | `submit(Class<T> responseType)` Submit the request for an asynchronous invocation and receive a future response of the specified type back.
    `<T> Future<T>` | `submit(GenericType<T> responseType)` Submit the request for an asynchronous invocation and receive a future response of the specified generic type back.
    `<T> Future<T>` | `submit(InvocationCallback<T> callback)` Submit the request for an asynchronous invocation and register an `InvocationCallback` to process the future result of the invocation.
    `void` | `writeRequestBody(OutputStream outputStream)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### client

          protected ResteasyClient client

    - #### headers

          protected ClientRequestHeaders headers

    - #### method

          protected String method

    - #### entity

          protected Object entity

    - #### entityGenericType

          protected Type entityGenericType

    - #### entityClass

          protected Class entityClass

    - #### entityAnnotations

          protected Annotation[] entityAnnotations

    - #### configuration

          protected ClientConfiguration configuration

    - #### uri

          protected URI uri

    - #### delegatingOutputStream

          protected DelegatingOutputStream delegatingOutputStream

    - #### entityStream

          protected OutputStream entityStream

  - ### Constructor Detail

    - #### ClientInvocation

          public ClientInvocation(ResteasyClient client,
                          URI uri,
                          ClientRequestHeaders headers,
                          ClientConfiguration parent)

  - ### Method Detail

    - #### extractResult

          public static <T> T extractResult(GenericType<T> responseType,
                            Response response,
                            Annotation[] annotations)

      Extracts result from response throwing an appropriate exception if not a successful response.
      Type Parameters:
        `T` -
      Parameters:
        `responseType` -
        `response` -
        `annotations` -
      Returns:

    - #### handleErrorStatus

          public static <T> T handleErrorStatus(Response response)

      Throw an exception. Expecting a status of 400 or greater.
      Type Parameters:
        `T` -
      Parameters:
        `response` -
      Returns:

    - #### getClientConfiguration

          public ClientConfiguration getClientConfiguration()

    - #### getClient

          public ResteasyClient getClient()

    - #### getDelegatingOutputStream

          public DelegatingOutputStream getDelegatingOutputStream()

    - #### setDelegatingOutputStream

          public void setDelegatingOutputStream(DelegatingOutputStream delegatingOutputStream)

    - #### getEntityStream

          public OutputStream getEntityStream()

    - #### setEntityStream

          public void setEntityStream(OutputStream entityStream)

    - #### getUri

          public URI getUri()

    - #### setUri

          public void setUri(URI uri)

    - #### getEntityAnnotations

          public Annotation[] getEntityAnnotations()

    - #### setEntityAnnotations

          public void setEntityAnnotations(Annotation[] entityAnnotations)

    - #### getMethod

          public String getMethod()

    - #### setMethod

          public void setMethod(String method)

    - #### setHeaders

          public void setHeaders(ClientRequestHeaders headers)

    - #### getMutableProperties

          public Map<String,Object> getMutableProperties()

    - #### getEntity

          public Object getEntity()

    - #### getEntityGenericType

          public Type getEntityGenericType()

    - #### getEntityClass

          public Class getEntityClass()

    - #### getHeaders

          public ClientRequestHeaders getHeaders()

    - #### setEntity

          public void setEntity(Entity entity)

    - #### setEntityObject

          public void setEntityObject(Object ent)

    - #### writeRequestBody

          public void writeRequestBody(OutputStream outputStream)
                                throws IOException

      Throws:
        `IOException`

    - #### getWriterInterceptors

          public WriterInterceptor[] getWriterInterceptors()

    - #### getRequestFilters

          public ClientRequestFilter[] getRequestFilters()

    - #### getResponseFilters

          public ClientResponseFilter[] getResponseFilters()

    - #### getConfiguration

          public Configuration getConfiguration()

    - #### invoke

          public Response invoke()

      Description copied from interface: `Invocation`
      Synchronously invoke the request and receive a response back.
      Specified by:
        `invoke` in interface `Invocation`
      Returns:
        `response` object as a result of the request invocation.

    - #### invoke

          public <T> T invoke(Class<T> responseType)

      Description copied from interface: `Invocation`
      Synchronously invoke the request and receive a response of the specified type back.
      Specified by:
        `invoke` in interface `Invocation`
      Type Parameters:
        `T` - response type
      Parameters:
        `responseType` - Java type the response should be converted into.
      Returns:
        response object of the specified type as a result of the request invocation.

    - #### invoke

          public <T> T invoke(GenericType<T> responseType)

      Description copied from interface: `Invocation`
      Synchronously invoke the request and receive a response of the specified generic type back.
      Specified by:
        `invoke` in interface `Invocation`
      Type Parameters:
        `T` - generic response type
      Parameters:
        `responseType` - type literal representing a generic Java type the response should be converted into.
      Returns:
        response object of the specified generic type as a result of the request invocation.

    - #### submit

          public Future<Response> submit()

      Description copied from interface: `Invocation`
      Submit the request for an asynchronous invocation and receive a future response back.

      Note that calling the `Future.get()` method on the returned `Future` instance may throw an `ExecutionException` that wraps a `ProcessingException` thrown in case of an invocation processing failure. In case a processing of a properly received response fails, the wrapped processing exception will be of `ResponseProcessingException` type and will contain the `Response` instance whose processing has failed.

      Specified by:
        `submit` in interface `Invocation`
      Returns:
        future `response` object as a result of the request invocation.

    - #### submit

          public <T> Future<T> submit(Class<T> responseType)

      Description copied from interface: `Invocation`
      Submit the request for an asynchronous invocation and receive a future response of the specified type back.

      Note that calling the `Future.get()` method on the returned `Future` instance may throw an `ExecutionException` that wraps either a `ProcessingException` thrown in case of an invocation processing failure or a `WebApplicationException` or one of its subclasses thrown in case the received response status code is not `successful` and the specified response type is not `Response`. In case a processing of a properly received response fails, the wrapped processing exception will be of `ResponseProcessingException` type and will contain the `Response` instance whose processing has failed.

      Specified by:
        `submit` in interface `Invocation`
      Type Parameters:
        `T` - response type
      Parameters:
        `responseType` - Java type the response should be converted into.
      Returns:
        future response object of the specified type as a result of the request invocation.

    - #### submit

          public <T> Future<T> submit(GenericType<T> responseType)

      Description copied from interface: `Invocation`
      Submit the request for an asynchronous invocation and receive a future response of the specified generic type back.

      Note that calling the `Future.get()` method on the returned `Future` instance may throw an `ExecutionException` that wraps either a `ProcessingException` thrown in case of an invocation processing failure or a `WebApplicationException` or one of its subclasses thrown in case the received response status code is not `successful` and the specified response type is not `Response`. In case a processing of a properly received response fails, the wrapped processing exception will be of `ResponseProcessingException` type and will contain the `Response` instance whose processing has failed.

      Specified by:
        `submit` in interface `Invocation`
      Type Parameters:
        `T` - generic response type
      Parameters:
        `responseType` - type literal representing a generic Java type the response should be converted into.
      Returns:
        future response object of the specified generic type as a result of the request invocation.

    - #### submit

          public <T> Future<T> submit(InvocationCallback<T> callback)

      Description copied from interface: `Invocation`
      Submit the request for an asynchronous invocation and register an `InvocationCallback` to process the future result of the invocation.

      Note that calling the `Future.get()` method on the returned `Future` instance may throw an `ExecutionException` that wraps either a `ProcessingException` thrown in case of an invocation processing failure or a `WebApplicationException` or one of its subclasses thrown in case the received response status code is not `successful` and the generic type of the supplied response callback is not `Response`. In case a processing of a properly received response fails, the wrapped processing exception will be of `ResponseProcessingException` type and will contain the `Response` instance whose processing has failed.

      Specified by:
        `submit` in interface `Invocation`
      Type Parameters:
        `T` - response type
      Parameters:
        `callback` - invocation callback for asynchronous processing of the request invocation result.
      Returns:
        future response object of the specified type as a result of the request invocation.

    - #### property

          public Invocation property(String name,
                            Object value)

      Description copied from interface: `Invocation`
      Set a new property in the context of a request represented by this invocation.

      The property is available for a later retrieval via `ClientRequestContext.getProperty(String)` or `InterceptorContext.getProperty(String)`. If a property with a given name is already set in the request context, the existing value of the property will be updated. Setting a `null` value into a property effectively removes the property from the request property bag.

      Specified by:
        `property` in interface `Invocation`
      Parameters:
        `name` - property name.
        `value` - (new) property value. `null` value removes the property with the given name.
      Returns:
        the updated invocation.
      See Also:
        `Invocation.Builder.property(String, Object)`

Copyright © 2014. All Rights Reserved.