Class JerseyInvocation
- java.lang.Object
-
- org.glassfish.jersey.client.JerseyInvocation
-
- All Implemented Interfaces:
Invocation
public class JerseyInvocation extends Object implements Invocation
Jersey implementation ofJAX-RS client-side request invocationcontract.- Author:
- Marek Potociar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJerseyInvocation.BuilderJersey-specificclient invocation builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Responseinvoke()Synchronously invoke the request and receive a response back.<T> Tinvoke(GenericType<T> responseType)Synchronously invoke the request and receive a response of the specified generic type back.<T> Tinvoke(Class<T> responseType)Synchronously invoke the request and receive a response of the specified type back.JerseyInvocationproperty(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(InvocationCallback<T> callback)Submit the request for an asynchronous invocation and register anInvocationCallbackto process the future result of the invocation.<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 anInvocationCallbackto process the future result of the invocation.<T> Future<T>submit(Class<T> responseType)Submit the request for an asynchronous invocation and receive a future response of the specified type back.StringtoString()
-
-
-
Method Detail
-
invoke
public Response invoke() throws ProcessingException, WebApplicationException
Description copied from interface:InvocationSynchronously invoke the request and receive a response back.- Specified by:
invokein interfaceInvocation- Returns:
responseobject 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
-
invoke
public <T> T invoke(Class<T> responseType) throws ProcessingException, WebApplicationException
Description copied from interface:InvocationSynchronously invoke the request and receive a response of the specified type back.- Specified by:
invokein interfaceInvocation- 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 notsuccessfuland the specified response type is notResponse.
-
invoke
public <T> T invoke(GenericType<T> responseType) throws ProcessingException, WebApplicationException
Description copied from interface:InvocationSynchronously invoke the request and receive a response of the specified generic type back.- Specified by:
invokein interfaceInvocation- 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 notsuccessful.
-
submit
public Future<Response> submit()
Description copied from interface:InvocationSubmit the request for an asynchronous invocation and receive a future response back.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps aProcessingExceptionthrown in case of an invocation processing failure. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- Returns:
- future
responseobject as a result of the request invocation.
-
submit
public <T> Future<T> submit(Class<T> responseType)
Description copied from interface:InvocationSubmit 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 returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the specified response type is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- 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:InvocationSubmit 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 returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the specified response type is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- 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:InvocationSubmit the request for an asynchronous invocation and register anInvocationCallbackto process the future result of the invocation.Note that calling the
Future.get()method on the returnedFutureinstance may throw anExecutionExceptionthat wraps either aProcessingExceptionthrown in case of an invocation processing failure or aWebApplicationExceptionor one of its subclasses thrown in case the received response status code is notsuccessfuland the generic type of the supplied response callback is notResponse. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingExceptiontype and will contain theResponseinstance whose processing has failed.- Specified by:
submitin interfaceInvocation- 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 anInvocationCallbackto process the future result of the invocation.Response type in this case is taken from
responseTypeparam (if notnull) rather than fromcallback. This allows to pass callbacks likenew InvocationCallback<>() {...}.- Type Parameters:
T- response type- Parameters:
responseType- response type that is used instead of obtaining types fromcallback.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 JerseyInvocation property(String name, Object value)
Description copied from interface:InvocationSet 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)orInterceptorContext.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 anullvalue into a property effectively removes the property from the request property bag.- Specified by:
propertyin interfaceInvocation- Parameters:
name- property name.value- (new) property value.nullvalue removes the property with the given name.- Returns:
- the updated invocation.
- See Also:
Invocation.Builder.property(String, Object)
-
-