Class JerseyInvocation

    • Method Detail

      • invoke

        public <T> T invoke​(Class<T> responseType)
                     throws ProcessingException,
                            WebApplicationException
        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.
        Throws:
        ResponseProcessingException - in case processing of a received HTTP response fails (e.g. in a filter or during conversion of the response entity data to an instance of a particular Java type).
        ProcessingException - in case the request processing or subsequent I/O operation fails.
        WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.
      • invoke

        public <T> T invoke​(GenericType<T> responseType)
                     throws ProcessingException,
                            WebApplicationException
        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.
        Throws:
        ResponseProcessingException - in case processing of a received HTTP response fails (e.g. in a filter or during conversion of the response entity data to an instance of a particular Java type).
        ProcessingException - in case the request processing or subsequent I/O operation fails.
        WebApplicationException - in case the response status code of the response returned by the server is not successful.
      • 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.
      • submit

        public <T> Future<T> submit​(GenericType<T> responseType,
                                    InvocationCallback<T> callback)
        Submit the request for an asynchronous invocation and register an InvocationCallback to process the future result of the invocation.

        Response type in this case is taken from responseType param (if not null) rather than from callback. This allows to pass callbacks like new InvocationCallback&lt;&gt() {...}.

        Type Parameters:
        T - response type
        Parameters:
        responseType - response type that is used instead of obtaining types from callback.
        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.