+
+ /**
+ * Use the <code>HttpClient</code> from Apaches <code>HttpComponents</code>
+ * for HTTP-requests.
+ *
+ * We also configure shorter intervals for the connection timeout and the
+ * read timeout.
+ *
+ * @param env The {@link Environment}, to read additional parameters from.
+ * @return The alternative implementation of {@link HttpRequestFactory}.
+ */
+ @Bean
+ public HttpComponentsClientHttpRequestFactory requestFactory(Environment env)
+ {
+ HttpComponentsClientHttpRequestFactory factory =
+ new HttpComponentsClientHttpRequestFactory();
+ factory.setConnectTimeout(
+ Integer.parseInt(env.getProperty("httpclient.timeout.connection"))
+ );
+ factory.setReadTimeout(
+ Integer.parseInt(env.getProperty("httpclient.timeout.read"))
+ );
+ return factory;
+ }