Class DefaultHttpClientProvider
java.lang.Object
com.atlassian.crowd.integration.rest.service.DefaultHttpClientProvider
- All Implemented Interfaces:
HttpClientProvider
Default implementation of
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault maximum number of connections in the pool.protected static final intThe maximum number of cache entries the http client cache will retain.protected static final intThe maximum response body size in bytes that will be eligible for caching in the http client. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.impl.client.cache.CacheConfigorg.apache.http.impl.client.CloseableHttpClientgetClient(ClientProperties clientProperties) Get anHttpClientinstance with the provided connection manager and request configuration.protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory>protected org.apache.http.impl.client.HttpClientBuildergetHttpClientBuilder(org.apache.http.conn.HttpClientConnectionManager connectionManager, org.apache.http.client.config.RequestConfig requestConfig) protected org.apache.http.impl.conn.PoolingHttpClientConnectionManagergetHttpClientConnectionManager(ClientProperties clientProperties, org.apache.http.conn.routing.HttpRoute httpRoute) protected org.apache.http.client.config.RequestConfiggetRequestConfig(ClientProperties clientProperties, org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager, org.apache.http.conn.routing.HttpRoute httpRoute) protected org.apache.http.conn.routing.HttpRouterouteFor(ClientProperties clientProperties) Create anHttpRoutewith a specific port by filling in the default withDefaultSchemePortResolver.
-
Field Details
-
MAX_CACHE_ENTRIES
protected static final int MAX_CACHE_ENTRIESThe maximum number of cache entries the http client cache will retain.- See Also:
-
MAX_OBJECT_SIZE
protected static final int MAX_OBJECT_SIZEThe maximum response body size in bytes that will be eligible for caching in the http client.- See Also:
-
DEFAULT_MAX_TOTAL_CONNECTIONS
protected static final int DEFAULT_MAX_TOTAL_CONNECTIONSDefault maximum number of connections in the pool.- See Also:
-
-
Constructor Details
-
DefaultHttpClientProvider
public DefaultHttpClientProvider()
-
-
Method Details
-
getClient
Description copied from interface:HttpClientProviderGet anHttpClientinstance with the provided connection manager and request configuration.- Specified by:
getClientin interfaceHttpClientProvider- Parameters:
clientProperties- the clientProperties for configuring theHttpClient.- Returns:
- an
HttpClientconfigured with the given connection manager and request config.
-
getConnectionSocketFactories
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> getConnectionSocketFactories() -
getHttpClientConnectionManager
protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager getHttpClientConnectionManager(ClientProperties clientProperties, org.apache.http.conn.routing.HttpRoute httpRoute) -
getHttpClientBuilder
protected org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder(org.apache.http.conn.HttpClientConnectionManager connectionManager, org.apache.http.client.config.RequestConfig requestConfig) -
getCacheConfig
protected org.apache.http.impl.client.cache.CacheConfig getCacheConfig() -
getRequestConfig
protected org.apache.http.client.config.RequestConfig getRequestConfig(ClientProperties clientProperties, org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager, org.apache.http.conn.routing.HttpRoute httpRoute) -
routeFor
Create anHttpRoutewith a specific port by filling in the default withDefaultSchemePortResolver.
-