javax.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 response = resourceTarget.request("text/plain")
               .header("Foo", "bar").async().get(String.class);
     
    • Method Detail

      • build

        Invocation build(String method)
        Build a request invocation using an arbitrary request method name.
        Parameters:
        method - request method name.
        Returns:
        invocation encapsulating the built request.
      • build

        Invocation build(String method,
                         Entity<?> entity)
        Build a request invocation using an arbitrary request method name and request entity.
        Parameters:
        method - request method name.
        entity - request entity, including it's full Variant information. Any variant-related HTTP headers previously set (namely Content-Type, Content-Language and Content-Encoding) will be overwritten using the entity variant information.
        Returns:
        invocation encapsulating the built request.
      • buildGet

        Invocation buildGet()
        Build a GET request invocation.
        Returns:
        invocation encapsulating the built GET request.
      • buildDelete

        Invocation buildDelete()
        Build a DELETE request invocation.
        Returns:
        invocation encapsulating the built DELETE request.
      • buildPost

        Invocation buildPost(Entity<?> entity)
        Build a POST request invocation.
        Parameters:
        entity - request entity, including it's full Variant information. Any variant-related HTTP headers previously set (namely Content-Type, Content-Language and Content-Encoding) will be overwritten using the entity variant information.
        Returns:
        invocation encapsulating the built POST request.
      • buildPut

        Invocation buildPut(Entity<?> entity)
        Build a PUT request invocation.
        Parameters:
        entity - request entity, including it's full Variant information. Any variant-related HTTP headers previously set (namely Content-Type, Content-Language and Content-Encoding) will be overwritten using the entity variant information.
        Returns:
        invocation encapsulating the built PUT request.
      • async

        AsyncInvoker async()
        Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.
        Returns:
        asynchronous uniform request invocation interface.
      • accept

        Invocation.Builder accept(String... mediaTypes)
        Add the accepted response media types.
        Parameters:
        mediaTypes - accepted response media types.
        Returns:
        the updated builder.
      • accept

        Invocation.Builder accept(MediaType... mediaTypes)
        Add the accepted response media types.
        Parameters:
        mediaTypes - accepted response media types.
        Returns:
        the updated builder.
      • acceptLanguage

        Invocation.Builder acceptLanguage(Locale... locales)
        Add acceptable languages.
        Parameters:
        locales - an array of the acceptable languages.
        Returns:
        the updated builder.
      • acceptLanguage

        Invocation.Builder acceptLanguage(String... locales)
        Add acceptable languages.
        Parameters:
        locales - an array of the acceptable languages.
        Returns:
        the updated builder.
      • acceptEncoding

        Invocation.Builder acceptEncoding(String... encodings)
        Add acceptable encodings.
        Parameters:
        encodings - an array of the acceptable encodings.
        Returns:
        the updated builder.
      • Invocation.Builder cookie(Cookie cookie)
        Add a cookie to be set.
        Parameters:
        cookie - to be set.
        Returns:
        the updated builder.
      • Invocation.Builder cookie(String name,
                                  String value)
        Add a cookie to be set.
        Parameters:
        name - the name of the cookie.
        value - the value of the cookie.
        Returns:
        the updated builder.
      • cacheControl

        Invocation.Builder cacheControl(CacheControl cacheControl)
        Set the cache control data of the message.
        Parameters:
        cacheControl - the cache control directives, if null any existing cache control directives will be removed.
        Returns:
        the updated builder.
      • headers

        Invocation.Builder headers(MultivaluedMap<String,Object> headers)
        Replaces all existing headers with the newly supplied headers.
        Parameters:
        headers - new headers to be set, if null all existing headers will be removed.
        Returns:
        the updated builder.

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.Builder.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

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com, Invocation.Builder (Java(TM) EE 7 Specification APIs)

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.