Last active
November 26, 2016 19:27
-
-
Save aboodz/f408087351524ec43b6fc17157e87ee4 to your computer and use it in GitHub Desktop.
using RESTeasy RestClientProxyFactoryBean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @ImportResource("classpath:springmvc-resteasy.xml") | |
| public class RestClientConfiguration { | |
| @Inject | |
| private Environment environment; | |
| @Bean | |
| public HttpClient httpClient() { | |
| PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); | |
| // Get the poolMaxTotal value from our application[-?].yml or default to 10 if not explicitly set | |
| connectionManager.setMaxTotal(environment.getProperty("poolMaxTotal", Integer.class, 10)); | |
| // TODO: explore more settings | |
| return HttpClientBuilder | |
| .create() | |
| .setConnectionManager(connectionManager) | |
| .build(); | |
| } | |
| @Bean | |
| @Inject | |
| public RestClientProxyFactoryBean<PingClient> restClientProxyFactoryBean(HttpClient httpClient) throws URISyntaxException { | |
| RestClientProxyFactoryBean<PingClient> restClientProxyFactoryBean = new RestClientProxyFactoryBean<>(); | |
| restClientProxyFactoryBean.setBaseUri(new URI("http://10.0.1.9:8787/restful-service/")); | |
| restClientProxyFactoryBean.setHttpClient(httpClient); // This is very important, the default http client is deprecated | |
| restClientProxyFactoryBean.setServiceInterface(PingClient.class); | |
| return restClientProxyFactoryBean; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment