Top Description Fields Constructors Methods
org.springframework.web.client.support

public final Class RestTemplateAdapter

extends Object
implements HttpExchangeAdapter
Class Inheritance
All Implemented Interfaces
org.springframework.web.service.invoker.HttpExchangeAdapter
Imports
java.net.URI, java.util.ArrayList, .List, org.springframework.core.ParameterizedTypeReference, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, .RequestEntity, .ResponseEntity, org.springframework.util.Assert, org.springframework.web.client.RestTemplate, org.springframework.web.service.invoker.HttpExchangeAdapter, .HttpRequestValues, .HttpServiceProxyFactory, org.springframework.web.util.UriBuilderFactory

HttpExchangeAdapter that enables an HttpServiceProxyFactory to use RestTemplate for request execution.

Use static factory methods in this class to create an HttpServiceProxyFactory configured with the given RestTemplate.

Authors
Olga Maciaszek-Sharma, Brian Clozel
Since
6.1

Field Summary

Modifier and TypeField and Description
private final RestTemplate

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static RestTemplateAdapter
create(RestTemplate restTemplate)

Create a RestTemplateAdapter for the given RestTemplate.

public void
exchange(HttpRequestValues
the request to perform
values
)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchange.

Perform the given request, and release the response content, if any.
public ResponseEntity<Void>
public <T> T
exchangeForBody(HttpRequestValues
the request to perform
values
,
ParameterizedTypeReference<T>
the target type to decode to
bodyType
)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForBody.

Perform the given request and decode the response content to the given type.
public <T> ResponseEntity<T>
public HttpHeaders
exchangeForHeaders(HttpRequestValues
the request to perform
values
)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForHeaders.

Perform the given request, release the response content, and return the response headers.
private RequestEntity<?>
public boolean
supportsRequestAttributes()

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.supportsRequestAttributes.

Whether the underlying client supports use of request attributes.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

restTemplateback to summary
private final RestTemplate restTemplate

Constructor Detail

RestTemplateAdapterback to summary
private RestTemplateAdapter(RestTemplate restTemplate)

Method Detail

createback to summary
public static RestTemplateAdapter create(RestTemplate restTemplate)

Create a RestTemplateAdapter for the given RestTemplate.

exchangeback to summary
public void exchange(HttpRequestValues values)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchange.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.exchange.

Perform the given request, and release the response content, if any.

Parameters
values:HttpRequestValues

the request to perform

Annotations
@Override
exchangeForBodilessEntityback to summary
public ResponseEntity<Void> exchangeForBodilessEntity(HttpRequestValues values)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForBodilessEntity.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForBodilessEntity.

Variant of exchange(HttpRequestValues) with additional access to the response status and headers.

Returns:ResponseEntity<Void>

the response entity with status and headers.

Annotations
@Override
exchangeForBodyback to summary
public <T> T exchangeForBody(HttpRequestValues values, ParameterizedTypeReference<T> bodyType)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForBody.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForBody.

Perform the given request and decode the response content to the given type.

Parameters
<T>
the type the response is decoded to
values:HttpRequestValues

the request to perform

bodyType:ParameterizedTypeReference<T>

the target type to decode to

Returns:T

the decoded response body.

Annotations
@Override
exchangeForEntityback to summary
public <T> ResponseEntity<T> exchangeForEntity(HttpRequestValues values, ParameterizedTypeReference<T> bodyType)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForEntity.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForEntity.

Variant of exchangeForBody(HttpRequestValues, ParameterizedTypeReference) with additional access to the response status and headers.

Returns:ResponseEntity<T>

the response entity with status, headers, and body.

Annotations
@Override
exchangeForHeadersback to summary
public HttpHeaders exchangeForHeaders(HttpRequestValues values)

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForHeaders.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.exchangeForHeaders.

Perform the given request, release the response content, and return the response headers.

Parameters
values:HttpRequestValues

the request to perform

Returns:HttpHeaders

the response headers

Annotations
@Override
newRequestback to summary
private RequestEntity<?> newRequest(HttpRequestValues values)
supportsRequestAttributesback to summary
public boolean supportsRequestAttributes()

Implements org.springframework.web.service.invoker.HttpExchangeAdapter.supportsRequestAttributes.

Doc from org.springframework.web.service.invoker.HttpExchangeAdapter.supportsRequestAttributes.

Whether the underlying client supports use of request attributes.

Annotations
@Override