/* * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.web.client; import java.net.URI; import java.util.Map; import java.util.Set; import java.util.concurrent.Future; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.lang.Nullable; import org.springframework.util.concurrent.ListenableFuture; /** * Interface specifying a basic set of asynchronous RESTful operations. * Implemented by {@link AsyncRestTemplate}. Not often used directly, but a useful * option to enhance testability, as it can easily be mocked or stubbed. * * @author Arjen Poutsma * @since 4.0 * @see AsyncRestTemplate * @see RestOperations * @deprecated as of Spring 5.0, in favor of {@link org.springframework.web.reactive.function.client.WebClient} */ @Deprecated public interface AsyncRestOperations { /** * Expose the synchronous Spring RestTemplate to allow synchronous invocation. */ RestOperations getRestOperations(); // GET /** * Asynchronously retrieve an entity by doing a GET on the specified URL. * The response is converted and stored in an {@link ResponseEntity}. *
URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param responseType the type of the return value
* @param uriVariables the variables to expand the template
* @return the entity wrapped in a {@link Future}
*/
URI Template variables are expanded using the given map.
* @param url the URL
* @param responseType the type of the return value
* @param uriVariables the map containing variables for the URI template
* @return the entity wrapped in a {@link Future}
*/
URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param uriVariables the variables to expand the template
* @return all HTTP headers of that resource wrapped in a {@link Future}
*/
ListenableFuture URI Template variables are expanded using the given map.
* @param url the URL
* @param uriVariables the map containing variables for the URI template
* @return all HTTP headers of that resource wrapped in a {@link Future}
*/
ListenableFuture URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the value for the {@code Location} header wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
ListenableFuture URI Template variables are expanded using the given map.
* @param url the URL
* @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the value for the {@code Location} header wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
ListenableFuture URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the entity wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
URI Template variables are expanded using the given map.
* @param url the URL
* @param request the Object to be POSTed (may be {@code null})
* @param uriVariables the variables to expand the template
* @return the entity wrapped in a {@link Future}
* @see org.springframework.http.HttpEntity
*/
URI Template variables are expanded using the given URI variables, if any.
* The Future will return a {@code null} result upon completion.
* @param url the URL
* @param request the Object to be PUT (may be {@code null})
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
ListenableFuture> put(String url, @Nullable HttpEntity> request, Object... uriVariables)
throws RestClientException;
/**
* 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 {@code null} result upon completion.
* @param url the URL
* @param request the Object to be PUT (may be {@code null})
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
ListenableFuture> put(String url, @Nullable HttpEntity> request, Map The Future will return a {@code null} result upon completion.
* @param url the URL
* @param request the Object to be PUT (may be {@code null})
* @see HttpEntity
*/
ListenableFuture> put(URI url, @Nullable HttpEntity> request) throws RestClientException;
// DELETE
/**
* 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 {@code null} result upon completion.
* @param url the URL
* @param uriVariables the variables to expand in the template
*/
ListenableFuture> delete(String url, Object... uriVariables) throws RestClientException;
/**
* 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 {@code null} result upon completion.
* @param url the URL
* @param uriVariables the variables to expand in the template
*/
ListenableFuture> delete(String url, Map URI Template variables are expanded using the given URI variables, if any.
* The Future will return a {@code null} result upon completion.
* @param url the URL
*/
ListenableFuture> delete(URI url) throws RestClientException;
// OPTIONS
/**
* Asynchronously return the value of the Allow header for the given URI.
* URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param uriVariables the variables to expand in the template
* @return the value of the allow header wrapped in a {@link Future}
*/
ListenableFuture URI Template variables are expanded using the given map.
* @param url the URL
* @param uriVariables the variables to expand in the template
* @return the value of the allow header wrapped in a {@link Future}
*/
ListenableFuture URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request
* (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
*/
URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request
* (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
*/
URI Template variables are expanded using the given URI variables, if any.
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestCallback object that prepares the request
* @param responseExtractor object that extracts the return value from the response
* @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
URI Template variables are expanded using the given URI variables map.
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestCallback object that prepares the request
* @param responseExtractor object that extracts the return value from the response
* @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
* ParameterizedTypeReference<List<MyBean>> myBean =
* new ParameterizedTypeReference<List<MyBean>>() {};
*
* ResponseEntity<List<MyBean>> response =
* template.exchange("https://example.com",HttpMethod.GET, null, myBean);
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the
* request (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
*/
* ParameterizedTypeReference<List<MyBean>> myBean =
* new ParameterizedTypeReference<List<MyBean>>() {};
*
* ResponseEntity<List<MyBean>> response =
* template.exchange("https://example.com",HttpMethod.GET, null, myBean);
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request
* (may be {@code null})
* @param responseType the type of the return value
* @param uriVariables the variables to expand in the template
* @return the response as entity wrapped in a {@link Future}
*/
* ParameterizedTypeReference<List<MyBean>> myBean =
* new ParameterizedTypeReference<List<MyBean>>() {};
*
* ResponseEntity<List<MyBean>> response =
* template.exchange("https://example.com",HttpMethod.GET, null, myBean);
*
* @param url the URL
* @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request
* (may be {@code null})
* @param responseType the type of the return value
* @return the response as entity wrapped in a {@link Future}
*/