Class DefaultHttpClientProvider

java.lang.Object
com.atlassian.crowd.integration.rest.service.DefaultHttpClientProvider
All Implemented Interfaces:
HttpClientProvider

public class DefaultHttpClientProvider extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
    Default maximum number of connections in the pool.
    protected static final int
    The maximum number of cache entries the http client cache will retain.
    protected static final int
    The maximum response body size in bytes that will be eligible for caching in the http client.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.http.impl.client.cache.CacheConfig
     
    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>
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_CACHE_ENTRIES

      protected static final int MAX_CACHE_ENTRIES
      The maximum number of cache entries the http client cache will retain.
      See Also:
    • MAX_OBJECT_SIZE

      protected static final int MAX_OBJECT_SIZE
      The 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_CONNECTIONS
      Default maximum number of connections in the pool.
      See Also:
  • Constructor Details

    • DefaultHttpClientProvider

      public DefaultHttpClientProvider()
  • Method Details

    • getClient

      public org.apache.http.impl.client.CloseableHttpClient getClient(ClientProperties clientProperties)
      Description copied from interface: HttpClientProvider
      Get an HttpClient instance with the provided connection manager and request configuration.
      Specified by:
      getClient in interface HttpClientProvider
      Parameters:
      clientProperties - the clientProperties for configuring the HttpClient.
      Returns:
      an HttpClient configured 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

      protected org.apache.http.conn.routing.HttpRoute routeFor(ClientProperties clientProperties)
      Create an HttpRoute with a specific port by filling in the default with DefaultSchemePortResolver.