public class DefaultHttpClientConfigurer extends Object implements HttpClientConfigurer, org.springframework.beans.factory.InitializingBean
This class adapts the configuration mechanism which was used with Commons HttpClient, which used a number of
specific Rice config params (see HttpClientParams
) to work with the HttpComponents HttpClient. The
configuration doesn't all map across nicely, so coverage is not perfect.
If the configuration parameters here are not sufficient, this implementation is designed to be extended.
Constructor and Description |
---|
DefaultHttpClientConfigurer() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Exercises the configuration to make it fail fast if there is a problem.
|
protected org.apache.http.conn.HttpClientConnectionManager |
buildConnectionManager()
Builds the HttpClientConnectionManager.
|
protected org.apache.http.client.config.RequestConfig |
buildRequestConfig()
Configures and builds the RequestConfig for the HttpClient.
|
protected org.apache.http.client.HttpRequestRetryHandler |
buildRetryHandler()
Builds the retry handler if
RETRY_SOCKET_EXCEPTION_PROPERTY is true in the project's configuration. |
protected org.apache.http.conn.ssl.SSLConnectionSocketFactory |
buildSslConnectionSocketFactory()
Builds the
SSLConnectionSocketFactory used in the connection manager's socket factory registry. |
void |
customizeHttpClient(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder)
Customizes the configuration of the httpClientBuilder.
|
public DefaultHttpClientConfigurer()
public void customizeHttpClient(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder)
Internally, this uses several helper methods to assist with configuring:
buildConnectionManager()
and sets the resulting HttpClientConnectionManager
(if
non-null) into the httpClientBuilder.buildRequestConfig()
and sets the resulting RequestConfig
(if non-null) into the
httpClientBuilder.buildRetryHandler()
and sets the resulting HttpRequestRetryHandler
(if non-null)
into the httpClientBuilder.customizeHttpClient
in interface HttpClientConfigurer
httpClientBuilder
- the httpClientBuilder being configuredprotected org.apache.http.conn.HttpClientConnectionManager buildConnectionManager()
Note that this calls buildSslConnectionSocketFactory()
and registers the resulting SSLConnectionSocketFactory
(if non-null) with its socket factory registry.
protected org.apache.http.client.HttpRequestRetryHandler buildRetryHandler()
RETRY_SOCKET_EXCEPTION_PROPERTY
is true in the project's configuration.protected org.apache.http.client.config.RequestConfig buildRequestConfig()
protected org.apache.http.conn.ssl.SSLConnectionSocketFactory buildSslConnectionSocketFactory()
SSLConnectionSocketFactory
used in the connection manager's socket factory registry.
Note that if KSBConstants.Config.KSB_ALLOW_SELF_SIGNED_SSL
is set to true
in the project configuration, this connection factory will be configured to accept self signed certs even if
the hostname doesn't match.
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
Copyright © 2005–2015 The Kuali Foundation. All rights reserved.