Class DefaultHttpClientConfigurer

java.lang.Object
org.kuali.rice.ksb.messaging.serviceconnectors.DefaultHttpClientConfigurer
All Implemented Interfaces:
HttpClientConfigurer, org.springframework.beans.factory.InitializingBean

public class DefaultHttpClientConfigurer extends Object implements HttpClientConfigurer, org.springframework.beans.factory.InitializingBean
Configures HttpClientBuilder instances for use by the HttpInvokerConnector.

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Exercises the configuration to make it fail fast if there is a problem.
    protected org.apache.http.conn.HttpClientConnectionManager
    Builds the HttpClientConnectionManager.
    protected org.apache.http.client.config.RequestConfig
    Configures and builds the RequestConfig for the HttpClient.
    protected org.apache.http.client.HttpRequestRetryHandler
    Builds the retry handler if RETRY_SOCKET_EXCEPTION_PROPERTY is true in the project's configuration.
    protected org.apache.http.conn.ssl.SSLConnectionSocketFactory
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 resulting HttpClientConnectionManager (if non-null) into the httpClientBuilder.
      • Calls buildRequestConfig() and sets the resulting RequestConfig (if non-null) into the httpClientBuilder.
      • Calls buildRetryHandler() and sets the resulting HttpRequestRetryHandler (if non-null) into the httpClientBuilder.
      Specified by:
      customizeHttpClient in interface HttpClientConfigurer
      Parameters:
      httpClientBuilder - the httpClientBuilder being configured
    • buildConnectionManager

      protected org.apache.http.conn.HttpClientConnectionManager buildConnectionManager()
      Builds the HttpClientConnectionManager.

      Note that this calls buildSslConnectionSocketFactory() and registers the resulting SSLConnectionSocketFactory (if non-null) with its socket factory registry.

      Returns:
      the HttpClientConnectionManager
    • buildRetryHandler

      protected org.apache.http.client.HttpRequestRetryHandler buildRetryHandler()
      Builds the retry handler if RETRY_SOCKET_EXCEPTION_PROPERTY is 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 the 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.

      Returns:
      the SSLConnectionSocketFactory
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Exercises the configuration to make it fail fast if there is a problem.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception