org.springframework.web.client

Class AsyncRestTemplate

    • Constructor Detail

      • AsyncRestTemplate

        public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory)
        Deprecated. 
        Create a new instance of the AsyncRestTemplate using the given AsyncClientHttpRequestFactory.

        This constructor will cast the given asynchronous AsyncClientHttpRequestFactory to a ClientHttpRequestFactory. Since all implementations of ClientHttpRequestFactory provided in Spring also implement AsyncClientHttpRequestFactory, this should not result in a ClassCastException.

      • AsyncRestTemplate

        public AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory,
                                 ClientHttpRequestFactory syncRequestFactory)
        Deprecated. 
        Creates a new instance of the AsyncRestTemplate using the given asynchronous and synchronous request factories.
        Parameters:
        asyncRequestFactory - the asynchronous request factory
        syncRequestFactory - the synchronous request factory
    • Method Detail

      • getErrorHandler

        public ResponseErrorHandler getErrorHandler()
        Deprecated. 
        Return the error handler.
      • setDefaultUriVariables

        public void setDefaultUriVariables(java.util.Map<java.lang.String,?> defaultUriVariables)
        Deprecated. 
        Configure default URI variable values. This is a shortcut for:
         DefaultUriTemplateHandler handler = new DefaultUriTemplateHandler();
         handler.setDefaultUriVariables(...);
        
         AsyncRestTemplate restTemplate = new AsyncRestTemplate();
         restTemplate.setUriTemplateHandler(handler);
         
        Parameters:
        defaultUriVariables - the default URI variable values
        Since:
        4.3
      • getUriTemplateHandler

        public UriTemplateHandler getUriTemplateHandler()
        Deprecated. 
        Return the configured URI template handler.
      • setMessageConverters

        public void setMessageConverters(java.util.List<HttpMessageConverter<?>> messageConverters)
        Deprecated. 
        Set the message body converters to use.

        These converters are used to convert from and to HTTP requests and responses.

      • getMessageConverters

        public java.util.List<HttpMessageConverter<?>> getMessageConverters()
        Deprecated. 
        Return the message body converters.
      • getForEntity

        public <T> ListenableFuture<ResponseEntity<T>> getForEntity(java.lang.String url,
                                                                    java.lang.Class<T> responseType,
                                                                    java.lang.Object... uriVariables)
                                                             throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously retrieve an entity by doing a GET on the specified URL. The response is converted and stored in an ResponseEntity.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        getForEntity in interface AsyncRestOperations
        Parameters:
        url - the URL
        responseType - the type of the return value
        uriVariables - the variables to expand the template
        Returns:
        the entity wrapped in a Future
        Throws:
        RestClientException
      • getForEntity

        public <T> ListenableFuture<ResponseEntity<T>> getForEntity(java.lang.String url,
                                                                    java.lang.Class<T> responseType,
                                                                    java.util.Map<java.lang.String,?> uriVariables)
                                                             throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously retrieve a representation by doing a GET on the URI template. The response is converted and stored in an ResponseEntity.

        URI Template variables are expanded using the given map.

        Specified by:
        getForEntity in interface AsyncRestOperations
        Parameters:
        url - the URL
        responseType - the type of the return value
        uriVariables - the map containing variables for the URI template
        Returns:
        the entity wrapped in a Future
        Throws:
        RestClientException
      • headForHeaders

        public ListenableFuture<HttpHeaders> headForHeaders(java.lang.String url,
                                                            java.lang.Object... uriVariables)
                                                     throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously retrieve all headers of the resource specified by the URI template.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        headForHeaders in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVariables - the variables to expand the template
        Returns:
        all HTTP headers of that resource wrapped in a Future
        Throws:
        RestClientException
      • headForHeaders

        public ListenableFuture<HttpHeaders> headForHeaders(java.lang.String url,
                                                            java.util.Map<java.lang.String,?> uriVariables)
                                                     throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously retrieve all headers of the resource specified by the URI template.

        URI Template variables are expanded using the given map.

        Specified by:
        headForHeaders in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVariables - the map containing variables for the URI template
        Returns:
        all HTTP headers of that resource wrapped in a Future
        Throws:
        RestClientException
      • postForLocation

        public ListenableFuture<java.net.URI> postForLocation(java.lang.String url,
                                                              @Nullable
                                                              HttpEntity<?> request,
                                                              java.lang.Object... uriVars)
                                                       throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Create a new resource by POSTing the given object to the URI template, and asynchronously returns the value of the Location header. This header typically indicates where the new resource is stored.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        postForLocation in interface AsyncRestOperations
        Parameters:
        url - the URL
        request - the Object to be POSTed (may be null)
        uriVars - the variables to expand the template
        Returns:
        the value for the Location header wrapped in a Future
        Throws:
        RestClientException
        See Also:
        HttpEntity
      • postForLocation

        public ListenableFuture<java.net.URI> postForLocation(java.lang.String url,
                                                              @Nullable
                                                              HttpEntity<?> request,
                                                              java.util.Map<java.lang.String,?> uriVars)
                                                       throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Create a new resource by POSTing the given object to the URI template, and asynchronously returns the value of the Location header. This header typically indicates where the new resource is stored.

        URI Template variables are expanded using the given map.

        Specified by:
        postForLocation in interface AsyncRestOperations
        Parameters:
        url - the URL
        request - the Object to be POSTed (may be null)
        uriVars - the variables to expand the template
        Returns:
        the value for the Location header wrapped in a Future
        Throws:
        RestClientException
        See Also:
        HttpEntity
      • put

        public ListenableFuture<?> put(java.lang.String url,
                                       @Nullable
                                       HttpEntity<?> request,
                                       java.lang.Object... uriVars)
                                throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Create or update a resource by PUTting the given object to the URI.

        URI Template variables are expanded using the given URI variables, if any.

        The Future will return a null result upon completion.

        Specified by:
        put in interface AsyncRestOperations
        Parameters:
        url - the URL
        request - the Object to be PUT (may be null)
        uriVars - the variables to expand the template
        Throws:
        RestClientException
        See Also:
        HttpEntity
      • put

        public ListenableFuture<?> put(java.lang.String url,
                                       @Nullable
                                       HttpEntity<?> request,
                                       java.util.Map<java.lang.String,?> uriVars)
                                throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Creates a new resource by PUTting the given object to URI template.

        URI Template variables are expanded using the given map.

        The Future will return a null result upon completion.

        Specified by:
        put in interface AsyncRestOperations
        Parameters:
        url - the URL
        request - the Object to be PUT (may be null)
        uriVars - the variables to expand the template
        Throws:
        RestClientException
        See Also:
        HttpEntity
      • delete

        public ListenableFuture<?> delete(java.lang.String url,
                                          java.lang.Object... uriVariables)
                                   throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously delete the resources at the specified URI.

        URI Template variables are expanded using the given URI variables, if any.

        The Future will return a null result upon completion.

        Specified by:
        delete in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVariables - the variables to expand in the template
        Throws:
        RestClientException
      • delete

        public ListenableFuture<?> delete(java.lang.String url,
                                          java.util.Map<java.lang.String,?> uriVariables)
                                   throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously delete the resources at the specified URI.

        URI Template variables are expanded using the given URI variables, if any.

        The Future will return a null result upon completion.

        Specified by:
        delete in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVariables - the variables to expand in the template
        Throws:
        RestClientException
      • optionsForAllow

        public ListenableFuture<java.util.Set<HttpMethod>> optionsForAllow(java.lang.String url,
                                                                           java.lang.Object... uriVars)
                                                                    throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously return the value of the Allow header for the given URI.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        optionsForAllow in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVars - the variables to expand in the template
        Returns:
        the value of the allow header wrapped in a Future
        Throws:
        RestClientException
      • optionsForAllow

        public ListenableFuture<java.util.Set<HttpMethod>> optionsForAllow(java.lang.String url,
                                                                           java.util.Map<java.lang.String,?> uriVars)
                                                                    throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously return the value of the Allow header for the given URI.

        URI Template variables are expanded using the given map.

        Specified by:
        optionsForAllow in interface AsyncRestOperations
        Parameters:
        url - the URL
        uriVars - the variables to expand in the template
        Returns:
        the value of the allow header wrapped in a Future
        Throws:
        RestClientException
      • exchange

        public <T> ListenableFuture<ResponseEntity<T>> exchange(java.lang.String url,
                                                                HttpMethod method,
                                                                @Nullable
                                                                HttpEntity<?> requestEntity,
                                                                java.lang.Class<T> responseType,
                                                                java.lang.Object... uriVariables)
                                                         throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        exchange in interface AsyncRestOperations
        Parameters:
        url - the URL
        method - the HTTP method (GET, POST, etc)
        requestEntity - the entity (headers and/or body) to write to the request (may be null)
        responseType - the type of the return value
        uriVariables - the variables to expand in the template
        Returns:
        the response as entity wrapped in a Future
        Throws:
        RestClientException
      • exchange

        public <T> ListenableFuture<ResponseEntity<T>> exchange(java.lang.String url,
                                                                HttpMethod method,
                                                                @Nullable
                                                                HttpEntity<?> requestEntity,
                                                                java.lang.Class<T> responseType,
                                                                java.util.Map<java.lang.String,?> uriVariables)
                                                         throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

        URI Template variables are expanded using the given URI variables, if any.

        Specified by:
        exchange in interface AsyncRestOperations
        Parameters:
        url - the URL
        method - the HTTP method (GET, POST, etc)
        requestEntity - the entity (headers and/or body) to write to the request (may be null)
        responseType - the type of the return value
        uriVariables - the variables to expand in the template
        Returns:
        the response as entity wrapped in a Future
        Throws:
        RestClientException
      • exchange

        public <T> ListenableFuture<ResponseEntity<T>> exchange(java.lang.String url,
                                                                HttpMethod method,
                                                                @Nullable
                                                                HttpEntity<?> requestEntity,
                                                                ParameterizedTypeReference<T> responseType,
                                                                java.lang.Object... uriVariables)
                                                         throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity. The given ParameterizedTypeReference is used to pass generic type information:
         ParameterizedTypeReference<List<MyBean>> myBean =
             new ParameterizedTypeReference<List<MyBean>>() {};
        
         ResponseEntity<List<MyBean>> response =
             template.exchange("http://example.com",HttpMethod.GET, null, myBean);
         
        Specified by:
        exchange in interface AsyncRestOperations
        Parameters:
        url - the URL
        method - the HTTP method (GET, POST, etc)
        requestEntity - the entity (headers and/or body) to write to the request (may be null)
        responseType - the type of the return value
        uriVariables - the variables to expand in the template
        Returns:
        the response as entity wrapped in a Future
        Throws:
        RestClientException
      • exchange

        public <T> ListenableFuture<ResponseEntity<T>> exchange(java.lang.String url,
                                                                HttpMethod method,
                                                                @Nullable
                                                                HttpEntity<?> requestEntity,
                                                                ParameterizedTypeReference<T> responseType,
                                                                java.util.Map<java.lang.String,?> uriVariables)
                                                         throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity. The given ParameterizedTypeReference is used to pass generic type information:
         ParameterizedTypeReference<List<MyBean>> myBean =
             new ParameterizedTypeReference<List<MyBean>>() {};
        
         ResponseEntity<List<MyBean>> response =
             template.exchange("http://example.com",HttpMethod.GET, null, myBean);
         
        Specified by:
        exchange in interface AsyncRestOperations
        Parameters:
        url - the URL
        method - the HTTP method (GET, POST, etc)
        requestEntity - the entity (headers and/or body) to write to the request (may be null)
        responseType - the type of the return value
        uriVariables - the variables to expand in the template
        Returns:
        the response as entity wrapped in a Future
        Throws:
        RestClientException
      • exchange

        public <T> ListenableFuture<ResponseEntity<T>> exchange(java.net.URI url,
                                                                HttpMethod method,
                                                                @Nullable
                                                                HttpEntity<?> requestEntity,
                                                                ParameterizedTypeReference<T> responseType)
                                                         throws RestClientException
        Deprecated. 
        Description copied from interface: AsyncRestOperations
        Asynchronously execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity. The given ParameterizedTypeReference is used to pass generic type information:
         ParameterizedTypeReference<List<MyBean>> myBean =
             new ParameterizedTypeReference<List<MyBean>>() {};
        
         ResponseEntity<List<MyBean>> response =
             template.exchange("http://example.com",HttpMethod.GET, null, myBean);
         
        Specified by:
        exchange in interface AsyncRestOperations
        Parameters:
        url - the URL
        method - the HTTP method (GET, POST, etc)
        requestEntity - the entity (headers and/or body) to write to the request (may be null)
        responseType - the type of the return value
        Returns:
        the response as entity wrapped in a Future
        Throws:
        RestClientException
      • acceptHeaderRequestCallback

        protected <T> AsyncRequestCallback acceptHeaderRequestCallback(java.lang.Class<T> responseType)
        Deprecated. 
        Returns a request callback implementation that prepares the request Accept headers based on the given response type and configured message converters.
      • httpEntityCallback

        protected <T> AsyncRequestCallback httpEntityCallback(@Nullable
                                                              HttpEntity<T> requestBody)
        Deprecated. 
        Returns a request callback implementation that writes the given object to the request stream.
      • httpEntityCallback

        protected <T> AsyncRequestCallback httpEntityCallback(@Nullable
                                                              HttpEntity<T> request,
                                                              java.lang.reflect.Type responseType)
        Deprecated. 
        Returns a request callback implementation that writes the given object to the request stream.