public class JerseyInvocation extends Object implements Invocation
JAX-RS client-side
request invocation contract.| Modifier and Type | Class and Description |
|---|---|
static class |
JerseyInvocation.Builder
Jersey-specific
client invocation builder. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
JerseyInvocation |
property(String name,
Object value)
Set a new property in the context of a request represented by this invocation.
|
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(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. |
<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. |
String |
toString() |
public Response invoke() throws ProcessingException, WebApplicationException
Invocationinvoke in interface Invocationresponse object as a result of the request invocation.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.WebApplicationExceptionpublic <T> T invoke(Class<T> responseType) throws ProcessingException, WebApplicationException
Invocationinvoke in interface InvocationT - response typeresponseType - Java type the response should be converted into.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.public <T> T invoke(GenericType<T> responseType) throws ProcessingException, WebApplicationException
Invocationinvoke in interface InvocationT - generic response typeresponseType - type literal representing a generic Java type the response should be converted into.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.public Future<Response> submit()
Invocation
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.
submit in interface Invocationresponse object as a result of the request invocation.public <T> Future<T> submit(Class<T> responseType)
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 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.
submit in interface InvocationT - response typeresponseType - Java type the response should be converted into.public <T> Future<T> submit(GenericType<T> responseType)
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 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.
submit in interface InvocationT - generic response typeresponseType - type literal representing a generic Java type the response should be converted into.public <T> Future<T> submit(InvocationCallback<T> callback)
InvocationInvocationCallback 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.
submit in interface InvocationT - response typecallback - invocation callback for asynchronous processing of the request invocation result.public <T> Future<T> submit(GenericType<T> responseType, InvocationCallback<T> callback)
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<>() {...}.
T - response typeresponseType - response type that is used instead of obtaining types from callback.callback - invocation callback for asynchronous processing of the
request invocation result.public JerseyInvocation property(String name, Object value)
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.
property in interface Invocationname - property name.value - (new) property value. null value removes the property with the given name.Invocation.Builder.property(String, Object)Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.