All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.social.partnercenter.http.client.RetryRestResource Maven / Gradle / Ivy

Go to download

A provider extension for Spring Social to enable connectivity with Microsoft and an API binding for Microsoft's Partner Center API.

There is a newer version: 10.11.0
Show newest version
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