Class AbstractHttpClientFactory
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientFactory
- All Implemented Interfaces:
HttpClientFactory
- Direct Known Subclasses:
DefaultHttpClientFactory
Abstract implementation of
HttpClientFactory
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.http.client.HttpClient
createHttpClient
(HttpDestinationProperties destination) Creates anHttpClient
based on the givenHttpDestinationProperties
.protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager
getConnectionManager
(HttpDestinationProperties destination) Get the connection manager for the HTTP client builder.protected org.apache.http.impl.client.HttpClientBuilder
getHttpClientBuilder
(HttpDestinationProperties destination) Get a preconfigured HTTP client builder instance.protected org.apache.http.client.config.RequestConfig.Builder
getRequestConfigBuilder
(HttpDestinationProperties destination) Get the request configuration builder for the HTTP client builder.protected org.apache.http.config.SocketConfig.Builder
getSocketConfigBuilder
(HttpDestinationProperties destination) Get the socket configuration builder for the HTTP client builder.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientFactory
createHttpClient
-
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 anHttpClient
based on the givenHttpDestinationProperties
.Caution: Implementations must ensure that this method is thread-safe.
- Specified by:
createHttpClient
in interfaceHttpClientFactory
- Parameters:
destination
- The destination to create theHttpClient
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 oneHttpClientConnectionManager
.- 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.
-