public class DefaultHttpClientProvider extends Object implements HttpClientProvider
HttpClientProvider
that creates http clients with client-side caching support.
This implementation uses a PoolingHttpClientConnectionManager
, which pools connections on a per-route basis,
and is able to service connection requests from multiple execution threads. Clients should call Closeable.close()
to cleanup resources held by the connection manager.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_TOTAL_CONNECTIONS
Default maximum number of connections in the pool.
|
protected static int |
MAX_CACHE_ENTRIES
The maximum number of cache entries the http client cache will retain.
|
protected static int |
MAX_OBJECT_SIZE
The maximum response body size in bytes that will be eligible for caching in the http client.
|
Constructor and Description |
---|
DefaultHttpClientProvider() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.http.impl.client.cache.CacheConfig |
getCacheConfig() |
org.apache.http.impl.client.CloseableHttpClient |
getClient(ClientProperties clientProperties)
Get an
HttpClient instance with the provided connection manager and request configuration. |
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> |
getConnectionSocketFactories() |
protected org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder(org.apache.http.conn.HttpClientConnectionManager connectionManager,
org.apache.http.client.config.RequestConfig requestConfig) |
protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager |
getHttpClientConnectionManager(ClientProperties clientProperties,
org.apache.http.conn.routing.HttpRoute httpRoute) |
protected org.apache.http.client.config.RequestConfig |
getRequestConfig(ClientProperties clientProperties,
org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager,
org.apache.http.conn.routing.HttpRoute httpRoute) |
protected org.apache.http.conn.routing.HttpRoute |
routeFor(ClientProperties clientProperties)
Create an
HttpRoute with a specific port by filling
in the default with DefaultSchemePortResolver . |
protected static final int MAX_CACHE_ENTRIES
protected static final int MAX_OBJECT_SIZE
protected static final int DEFAULT_MAX_TOTAL_CONNECTIONS
public org.apache.http.impl.client.CloseableHttpClient getClient(ClientProperties clientProperties)
HttpClientProvider
HttpClient
instance with the provided connection manager and request configuration.getClient
in interface HttpClientProvider
clientProperties
- the clientProperties for configuring the HttpClient
.HttpClient
configured with the given connection manager and request config.protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> getConnectionSocketFactories()
protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager getHttpClientConnectionManager(ClientProperties clientProperties, org.apache.http.conn.routing.HttpRoute httpRoute)
protected org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(org.apache.http.conn.HttpClientConnectionManager connectionManager, org.apache.http.client.config.RequestConfig requestConfig)
protected org.apache.http.impl.client.cache.CacheConfig getCacheConfig()
protected org.apache.http.client.config.RequestConfig getRequestConfig(ClientProperties clientProperties, org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager, org.apache.http.conn.routing.HttpRoute httpRoute)
protected org.apache.http.conn.routing.HttpRoute routeFor(ClientProperties clientProperties)
HttpRoute
with a specific port by filling
in the default with DefaultSchemePortResolver
.Copyright © 2021 Atlassian. All rights reserved.