Class DefaultHttpClientConfigurer
- All Implemented Interfaces:
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.
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidExercises the configuration to make it fail fast if there is a problem.protected org.apache.http.conn.HttpClientConnectionManagerBuilds the HttpClientConnectionManager.protected org.apache.http.client.config.RequestConfigConfigures and builds the RequestConfig for the HttpClient.protected org.apache.http.client.HttpRequestRetryHandlerBuilds the retry handler ifRETRY_SOCKET_EXCEPTION_PROPERTYis true in the project's configuration.protected org.apache.http.conn.ssl.SSLConnectionSocketFactoryBuilds theSSLConnectionSocketFactoryused in the connection manager's socket factory registry.voidcustomizeHttpClient(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Customizes the configuration of the httpClientBuilder.
-
Constructor Details
-
DefaultHttpClientConfigurer
public DefaultHttpClientConfigurer()
-
-
Method Details
-
customizeHttpClient
public void customizeHttpClient(org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Customizes the configuration of the httpClientBuilder.Internally, this uses several helper methods to assist with configuring:
- Calls
buildConnectionManager()and sets the resultingHttpClientConnectionManager(if non-null) into the httpClientBuilder. - Calls
buildRequestConfig()and sets the resultingRequestConfig(if non-null) into the httpClientBuilder. - Calls
buildRetryHandler()and sets the resultingHttpRequestRetryHandler(if non-null) into the httpClientBuilder.
- Specified by:
customizeHttpClientin interfaceHttpClientConfigurer- Parameters:
httpClientBuilder- the httpClientBuilder being configured
- Calls
-
buildConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager buildConnectionManager()Builds the HttpClientConnectionManager.Note that this calls
buildSslConnectionSocketFactory()and registers the resultingSSLConnectionSocketFactory(if non-null) with its socket factory registry.- Returns:
- the HttpClientConnectionManager
-
buildRetryHandler
protected org.apache.http.client.HttpRequestRetryHandler buildRetryHandler()Builds the retry handler ifRETRY_SOCKET_EXCEPTION_PROPERTYis true in the project's configuration.- Returns:
- the HttpRequestRetryHandler or null depending on configuration
-
buildRequestConfig
protected org.apache.http.client.config.RequestConfig buildRequestConfig()Configures and builds the RequestConfig for the HttpClient.- Returns:
- the RequestConfig
-
buildSslConnectionSocketFactory
protected org.apache.http.conn.ssl.SSLConnectionSocketFactory buildSslConnectionSocketFactory()Builds theSSLConnectionSocketFactoryused in the connection manager's socket factory registry.Note that if
KSBConstants.Config.KSB_ALLOW_SELF_SIGNED_SSLis 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.- Returns:
- the SSLConnectionSocketFactory
-
afterPropertiesSet
Exercises the configuration to make it fail fast if there is a problem.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-