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

public final Class RestClientAdapter

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, .ResponseEntity, org.springframework.util.Assert, org.springframework.web.client.RestClient, org.springframework.web.service.invoker.HttpExchangeAdapter, .HttpRequestValues, .HttpServiceProxyFactory, org.springframework.web.util.UriBuilderFactory

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

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

Authors
Olga Maciaszek-Sharma, Rossen Stoyanchev
Since
6.1

Field Summary

Modifier and TypeField and Description
private final RestClient

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static RestClientAdapter
create(RestClient restClient)

Create a RestClientAdapter for the given RestClient.

public void
exchange(HttpRequestValues
the request to perform
requestValues
)

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 RestClient.RequestBodySpec
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

restClientback to summary
private final RestClient restClient

Constructor Detail

RestClientAdapterback to summary
private RestClientAdapter(RestClient restClient)

Method Detail

createback to summary
public static RestClientAdapter create(RestClient restClient)

Create a RestClientAdapter for the given RestClient.

exchangeback to summary
public void exchange(HttpRequestValues requestValues)

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
requestValues: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 RestClient.RequestBodySpec 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