-
public interface Invocation
A client request invocation. An invocation is a request that has been prepared and is ready for execution. Invocations provide a generic (command) interface that enables a separation of concerns between the creator and the submitter. In particular, the submitter does not need to know how the invocation was prepared, but only how it should be executed (synchronously or asynchronously) and when.- Author:
- Marek Potociar
- See Also:
Invocation.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface and Description static interface
Invocation.Builder
A client request invocation builder.
-
Method Summary
All Methods Instance Methods Abstract Methods 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.Invocation
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(InvocationCallback<T> callback)
Submit the request for an asynchronous invocation and register anInvocationCallback
to process the future result of the invocation.
-
-
-
Method Detail
-
property
Invocation property(String name, Object value)
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)
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 anull
value into a property effectively removes the property from the request property bag.- 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)
-
invoke
Response invoke()
Synchronously invoke the request and receive a response back.- Returns:
response
object 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.
-
invoke
<T> T invoke(Class<T> responseType)
Synchronously invoke the request and receive a response of the specified type back.- 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 notsuccessful
.
-
invoke
<T> T invoke(GenericType<T> responseType)
Synchronously invoke the request and receive a response of the specified generic type back.- 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
Future<Response> submit()
Submit the request for an asynchronous invocation and receive a future response back.Note that calling the
Future.get()
method on the returnedFuture
instance may throw anExecutionException
that wraps aProcessingException
thrown in case of an invocation processing failure. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingException
type and will contain theResponse
instance whose processing has failed.- Returns:
- future
response
object as a result of the request invocation.
-
submit
<T> Future<T> submit(Class<T> responseType)
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 returnedFuture
instance may throw anExecutionException
that wraps either aProcessingException
thrown in case of an invocation processing failure or aWebApplicationException
or one of its subclasses thrown in case the received response status code is notsuccessful
and the specified response type is notResponse
. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingException
type and will contain theResponse
instance whose processing has failed.- 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
<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.Note that calling the
Future.get()
method on the returnedFuture
instance may throw anExecutionException
that wraps either aProcessingException
thrown in case of an invocation processing failure or aWebApplicationException
or one of its subclasses thrown in case the received response status code is notsuccessful
and the specified response type is notResponse
. In case a processing of a properly received response fails, the wrapped processing exception will be ofResponseProcessingException
type and will contain theResponse
instance whose processing has failed.- 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
<T> Future<T> submit(InvocationCallback<T> callback)
Submit the request for an asynchronous invocation and register anInvocationCallback
to process the future result of the invocation.Note that calling the
Future.get()
method on the returnedFuture
instance may throw anExecutionException
that wraps either aProcessingException
thrown in case of an invocation processing failure or aWebApplicationException
or one of its subclasses thrown in case the received response status code is notsuccessful
and 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 ofResponseProcessingException
type and will contain theResponse
instance whose processing has failed.- 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.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/ws/rs/client/invocation.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.