Class AbstractHttpClientFactory

java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientFactory
All Implemented Interfaces:
HttpClientFactory
Direct Known Subclasses:
DefaultHttpClientFactory

public abstract class AbstractHttpClientFactory extends Object implements HttpClientFactory
Abstract implementation of HttpClientFactory.
  • Constructor Details

    • AbstractHttpClientFactory

      public AbstractHttpClientFactory()
  • Method Details

    • createHttpClient

      @Nonnull public org.apache.http.client.HttpClient createHttpClient(@Nullable HttpDestinationProperties destination) throws DestinationAccessException, HttpClientInstantiationException
      Description copied from interface: HttpClientFactory
      Creates an HttpClient based on the given HttpDestinationProperties.

      Caution: Implementations must ensure that this method is thread-safe.

      Specified by:
      createHttpClient in interface HttpClientFactory
      Parameters:
      destination - The destination to create the HttpClient for.
      Returns:
      An HttpClient based on the given Destination.
      Throws:
      DestinationAccessException - if the type of the destination is not HTTP.
      HttpClientInstantiationException - if there occurred an error during the creation of the client.
    • getRequestConfigBuilder

      @Nonnull protected org.apache.http.client.config.RequestConfig.Builder getRequestConfigBuilder(@Nullable HttpDestinationProperties destination)
      Get the request configuration builder for the HTTP client builder.
      Parameters:
      destination - The optional destination reference.
      Returns:
      A request configuration builder reference.
    • getSocketConfigBuilder

      @Nonnull protected org.apache.http.config.SocketConfig.Builder getSocketConfigBuilder(@Nullable HttpDestinationProperties destination)
      Get the socket configuration builder for the HTTP client builder.
      Parameters:
      destination - The optional destination reference.
      Returns:
      A socket configuration builder reference.
    • getHttpClientBuilder

      protected org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(@Nullable HttpDestinationProperties destination) throws HttpClientInstantiationException
      Get a preconfigured HTTP client builder instance.
      Parameters:
      destination - The optional destination reference to create a client builder for.
      Returns:
      A new and preconfigured instance of HTTP client builder.
      Throws:
      HttpClientInstantiationException - if there occurred an error during the configuration of the client builder.
    • getConnectionManager

      @Nonnull protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager getConnectionManager(@Nullable HttpDestinationProperties destination) throws GeneralSecurityException, IOException
      Get the connection manager for the HTTP client builder.

      Note: Since the destination may have custom TLS/SSL settings, the returned connection manager shall not be cached or reused. As a result the cardinality is: One HttpClient to one HttpClientConnectionManager.

      Parameters:
      destination - The optional destination reference.
      Returns:
      An optional connection manager instance.
      Throws:
      IOException - If trust store or key store could not be loaded.
      GeneralSecurityException - If trust store or key store could not be loaded.