@@ -0,0 +1,1849 @@
+/*%0A * Copyright 2017 Open mHealth%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0A%0Apackage org.openmhealth.shimmer.common.configuration;%0A%0Aimport org.apache.http.client.HttpClient;%0Aimport org.apache.http.impl.client.HttpClientBuilder;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.http.client.ClientHttpRequestFactory;%0Aimport org.springframework.http.client.HttpComponentsClientHttpRequestFactory;%0A%0A%0A/**%0A * A configuration for an Apache HttpComponents request factory that enables connection pooling, timeouts, and%0A * potentially request logging.%0A *%0A * @author Emerson Farrugia%0A */%0A@Configuration%0Apublic class HttpClientConfiguration %7B%0A%0A    @Bean%0A    public HttpClient httpClient() %7B%0A%0A        return HttpClientBuilder.create()%0A                .setMaxConnPerRoute(20) // chosen without much thought, refine at will%0A                .setMaxConnTotal(100)%0A                .build();%0A    %7D%0A%0A    @Bean%0A    public ClientHttpRequestFactory clientHttpRequestFactory() %7B%0A%0A        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient());%0A%0A        factory.setReadTimeout(30_000); // chosen without much thought, refine at will%0A        factory.setConnectTimeout(5_000);%0A%0A        return factory;%0A    %7D%0A%7D%0A

Add HTTP connection pooling support