org.springframework.social.partnercenter.http.client.RetryRestResource Maven / Gradle / Ivy
package org.springframework.social.partnercenter.http.client;
import java.net.URI;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.social.partnercenter.http.client.retry.RetryService;
import org.springframework.web.client.RestTemplate;
public class RetryRestResource extends RestResource {
private final RetryService retryService;
public RetryRestResource(RestTemplate restTemplate, String resourceBaseUri, RetryService retryService) {
super(restTemplate, resourceBaseUri);
this.retryService = retryService;
}
@Override
public R execute(URI uri, HttpMethod httpMethod, HttpEntity entity, Class responseType) {
return retryService.doWithRetry(() ->
getRestTemplate().exchange(
uri,
httpMethod,
entity,
responseType
).getBody()
);
}
@Override
public R execute(URI uri, HttpMethod httpMethod, HttpEntity entity, ParameterizedTypeReference responseType) {
return retryService.doWithRetry(() ->
getRestTemplate().exchange(
uri,
httpMethod,
entity,
responseType
).getBody()
);
}
@Override
public void delete(URI uri) {
retryService.doWithRetry(() -> getRestTemplate().delete(uri));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy