protected void initializeRestTemplate(){
		connectionManager = buildConnectionManager();
		if (connectionManager == null){			// should use JDK rather than HttpClient
			restTemplate = new RestTemplate();
		}else{
			if (connectionManager instanceof PoolingHttpClientConnectionManager){
				configureConnectionManager((PoolingHttpClientConnectionManager)connectionManager);
			}
			HttpRequestRetryHandler retryHandler = buildRequestRetryHandler();
			HttpClientBuilder clientBuilder = HttpClients.custom().setConnectionManager(connectionManager);
			configureHttpClient(clientBuilder);
			clientBuilder.setRetryHandler(retryHandler);
			CloseableHttpClient httpClient = clientBuilder.build();
			
			HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
			configureRequestFactory(requestFactory);
			
			restTemplate = new RestTemplate(requestFactory);
		}
		configureRequestFactory(restTemplate.getRequestFactory());
		configureMessageConverters(restTemplate.getMessageConverters());
		configureRestTemplate(restTemplate);
	}
protected void initializeRestTemplate ( ) { connectionManager = buildConnectionManager ( ) ; if ( connectionManager == null ) { restTemplate = new RestTemplate ( ) ; } else { if ( connectionManager instanceof PoolingHttpClientConnectionManager ) { configureConnectionManager ( ( PoolingHttpClientConnectionManager ) connectionManager ) ; } HttpRequestRetryHandler retryHandler = buildRequestRetryHandler ( ) ; HttpClientBuilder clientBuilder = HttpClients . custom ( ) . setConnectionManager ( connectionManager ) ; configureHttpClient ( clientBuilder ) ; clientBuilder . setRetryHandler ( retryHandler ) ; CloseableHttpClient httpClient = clientBuilder . build ( ) ; HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory ( httpClient ) ; configureRequestFactory ( requestFactory ) ; restTemplate = new RestTemplate ( requestFactory ) ; } configureRequestFactory ( restTemplate . getRequestFactory ( ) ) ; configureMessageConverters ( restTemplate . getMessageConverters ( ) ) ; configureRestTemplate ( restTemplate ) ; }
Initialize the RestTemplate internally. In simple usage scenarios, this method
should be called from within the constructor of the subclass.
Or, if running inside a Spring context, subclass may call this method
from within {@link org.springframework.beans.factory.InitializingBean#afterPropertiesSet()} method.