Package jakarta.ws.rs.client
Interface Invocation.Builder
- All Superinterfaces:
- SyncInvoker
- Enclosing interface:
- Invocation
public static interface Invocation.Builder extends SyncInvoker
A client request invocation builder.
 The builder, obtained via a call to one of the 
request(...) methods on a resource target,
 provides methods for preparing a client request invocation. Once the request is prepared the invocation builder can
 be either used to build an Invocation with a generic execution interface:
 
 Client client = ClientBuilder.newClient();
 WebTarget resourceTarget = client.target("http://examples.jaxrs.com/");
 // Build a HTTP GET request that accepts "text/plain" response type
 // and contains a custom HTTP header entry "Foo: bar".
 Invocation invocation = resourceTarget.request("text/plain")
         .header("Foo", "bar").buildGet();
 // Invoke the request using generic interface
 String response = invocation.invoke(String.class);
 
 Alternatively, one of the inherited synchronous invocation methods can be used to invoke the
 prepared request and return the server response in a single step, e.g.:
 
 Client client = ClientBuilder.newClient();
 WebTarget resourceTarget = client.target("http://examples.jaxrs.com/");
 // Build and invoke the get request in a single step
 String response = resourceTarget.request("text/plain")
         .header("Foo", "bar").get(String.class);
 
 Once the request is fully prepared for invoking, switching to an asynchronous invocation mode is
 possible by calling the async() method on the builder, e.g.:
 
 Client client = ClientBuilder.newClient();
 WebTarget resourceTarget = client.target("http://examples.jaxrs.com/");
 // Build and invoke the get request asynchronously in a single step
 Future<String> response = resourceTarget.request("text/plain")
         .header("Foo", "bar").async().get(String.class);
 - 
Method SummaryModifier and Type Method Description Invocation.Builderaccept(MediaType... mediaTypes)Add the accepted response media types.Invocation.Builderaccept(String... mediaTypes)Add the accepted response media types.Invocation.BuilderacceptEncoding(String... encodings)Add acceptable encodings.Invocation.BuilderacceptLanguage(String... locales)Add acceptable languages.Invocation.BuilderacceptLanguage(Locale... locales)Add acceptable languages.AsyncInvokerasync()Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.Invocationbuild(String method)Build a request invocation using an arbitrary request method name.Invocationbuild(String method, Entity<?> entity)Build a request invocation using an arbitrary request method name and request entity.InvocationbuildDelete()Build a DELETE request invocation.InvocationbuildGet()Build a GET request invocation.InvocationbuildPost(Entity<?> entity)Build a POST request invocation.InvocationbuildPut(Entity<?> entity)Build a PUT request invocation.Invocation.BuildercacheControl(CacheControl cacheControl)Set the cache control data of the message.Invocation.Buildercookie(Cookie cookie)Add a cookie to be set.Invocation.Buildercookie(String name, String value)Add a cookie to be set.Invocation.Builderheader(String name, Object value)Add an arbitrary header.Invocation.Builderheaders(MultivaluedMap<String,Object> headers)Replaces all existing headers with the newly supplied headers.Invocation.Builderproperty(String name, Object value)Set a new property in the context of a request represented by this invocation builder.CompletionStageRxInvokerrx()Access the default reactive invoker based onCompletionStage.<T extends RxInvoker>
 Trx(Class<T> clazz)Access a reactive invoker based on aRxInvokersubclass provider.
- 
Method Details- 
buildBuild a request invocation using an arbitrary request method name.- Parameters:
- method- request method name.
- Returns:
- invocation encapsulating the built request.
 
- 
buildBuild a request invocation using an arbitrary request method name and request entity.- Parameters:
- method- request method name.
- entity- request entity, including it's full- Variantinformation. Any variant-related HTTP headers previously set (namely- Content-Type,- Content-Languageand- Content-Encoding) will be overwritten using the entity variant information.
- Returns:
- invocation encapsulating the built request.
 
- 
buildGetInvocation buildGet()Build a GET request invocation.- Returns:
- invocation encapsulating the built GET request.
 
- 
buildDeleteInvocation buildDelete()Build a DELETE request invocation.- Returns:
- invocation encapsulating the built DELETE request.
 
- 
buildPostBuild a POST request invocation.- Parameters:
- entity- request entity, including it's full- Variantinformation. Any variant-related HTTP headers previously set (namely- Content-Type,- Content-Languageand- Content-Encoding) will be overwritten using the entity variant information.
- Returns:
- invocation encapsulating the built POST request.
 
- 
buildPutBuild a PUT request invocation.- Parameters:
- entity- request entity, including it's full- Variantinformation. Any variant-related HTTP headers previously set (namely- Content-Type,- Content-Languageand- Content-Encoding) will be overwritten using the entity variant information.
- Returns:
- invocation encapsulating the built PUT request.
 
- 
asyncAsyncInvoker async()Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.- Returns:
- asynchronous uniform request invocation interface.
 
- 
acceptAdd the accepted response media types.- Parameters:
- mediaTypes- accepted response media types.
- Returns:
- the updated builder.
 
- 
acceptAdd the accepted response media types.- Parameters:
- mediaTypes- accepted response media types.
- Returns:
- the updated builder.
 
- 
acceptLanguageAdd acceptable languages.- Parameters:
- locales- an array of the acceptable languages.
- Returns:
- the updated builder.
 
- 
acceptLanguageAdd acceptable languages.- Parameters:
- locales- an array of the acceptable languages.
- Returns:
- the updated builder.
 
- 
acceptEncodingAdd acceptable encodings.- Parameters:
- encodings- an array of the acceptable encodings.
- Returns:
- the updated builder.
 
- 
cookieAdd a cookie to be set.- Parameters:
- cookie- to be set.
- Returns:
- the updated builder.
 
- 
cookieAdd a cookie to be set.- Parameters:
- name- the name of the cookie.
- value- the value of the cookie.
- Returns:
- the updated builder.
 
- 
cacheControlSet the cache control data of the message.- Parameters:
- cacheControl- the cache control directives, if- nullany existing cache control directives will be removed.
- Returns:
- the updated builder.
 
- 
headerAdd an arbitrary header.- Parameters:
- name- the name of the header
- value- the value of the header, the header will be serialized using a- RuntimeDelegate.HeaderDelegateif one is available via- RuntimeDelegate.createHeaderDelegate(java.lang.Class)for the class of- valueor using its- toStringmethod if a header delegate is not available. If- valueis- nullthen all current headers of the same name will be removed.
- Returns:
- the updated builder.
 
- 
headersReplaces all existing headers with the newly supplied headers.- Parameters:
- headers- new headers to be set, if- nullall existing headers will be removed.
- Returns:
- the updated builder.
 
- 
propertySet a new property in the context of a request represented by this invocation builder.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.- Parameters:
- name- property name.
- value- (new) property value.- nullvalue removes the property with the given name.
- Returns:
- the updated builder.
- See Also:
- Invocation.property(String, Object)
 
- 
rxAccess the default reactive invoker based onCompletionStage.- Returns:
- default reactive invoker instance.
- Since:
- 2.1
- See Also:
- rx(Class)
 
- 
rxAccess a reactive invoker based on aRxInvokersubclass provider. Note that correspondingRxInvokerProvidermust be registered in the client runtime.This method is an extension point for JAX-RS implementations to support other types representing asynchronous computations. - Type Parameters:
- T- generic invoker type.
- Parameters:
- clazz-- RxInvokersubclass.
- Returns:
- reactive invoker instance.
- Throws:
- IllegalStateException- when provider for given class is not registered.
- Since:
- 2.1
- See Also:
- Configurable.register(Class)
 
 
-