Class HttpAsyncClientBuilder
- java.lang.Object
-
- org.apache.http.impl.nio.client.HttpAsyncClientBuilder
-
public class HttpAsyncClientBuilder extends java.lang.ObjectBuilder forCloseableHttpAsyncClientinstances.When a particular component is not explicitly this class will use its default implementation. System properties will be taken into account when configuring the default implementations when
useSystemProperties()method is called prior to callingbuild().- ssl.TrustManagerFactory.algorithm
- javax.net.ssl.trustStoreType
- javax.net.ssl.trustStore
- javax.net.ssl.trustStoreProvider
- javax.net.ssl.trustStorePassword
- ssl.KeyManagerFactory.algorithm
- javax.net.ssl.keyStoreType
- javax.net.ssl.keyStore
- javax.net.ssl.keyStoreProvider
- javax.net.ssl.keyStorePassword
- https.protocols
- https.cipherSuites
- http.proxyHost
- http.proxyPort
- http.keepAlive
- http.maxConnections
- http.agent
Please note that some settings used by this class can be mutually exclusive and may not apply when building
CloseableHttpAsyncClientinstances.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private booleanauthCachingDisabledprivate org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider>authSchemeRegistryprivate booleanconnectionStateDisabledprivate NHttpClientConnectionManagerconnManagerprivate booleanconnManagerSharedprivate booleancookieManagementDisabledprivate org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider>cookieSpecRegistryprivate org.apache.http.client.CookieStorecookieStoreprivate org.apache.http.client.CredentialsProvidercredentialsProviderprivate org.apache.http.config.ConnectionConfigdefaultConnectionConfigprivate java.util.Collection<? extends org.apache.http.Header>defaultHeadersprivate org.apache.http.impl.nio.reactor.IOReactorConfigdefaultIOReactorConfigprivate org.apache.http.client.config.RequestConfigdefaultRequestConfigprivate org.apache.http.nio.NHttpClientEventHandlereventHandlerprivate javax.net.ssl.HostnameVerifierhostnameVerifierprivate org.apache.http.protocol.HttpProcessorhttpprocessorprivate org.apache.http.conn.ConnectionKeepAliveStrategykeepAliveStrategyprivate intmaxConnPerRouteprivate intmaxConnTotalprivate org.apache.http.HttpHostproxyprivate org.apache.http.client.AuthenticationStrategyproxyAuthStrategyprivate org.apache.http.conn.util.PublicSuffixMatcherpublicSuffixMatcherprivate org.apache.http.client.RedirectStrategyredirectStrategyprivate java.util.LinkedList<org.apache.http.HttpRequestInterceptor>requestFirstprivate java.util.LinkedList<org.apache.http.HttpRequestInterceptor>requestLastprivate java.util.LinkedList<org.apache.http.HttpResponseInterceptor>responseFirstprivate java.util.LinkedList<org.apache.http.HttpResponseInterceptor>responseLastprivate org.apache.http.ConnectionReuseStrategyreuseStrategyprivate org.apache.http.conn.routing.HttpRoutePlannerroutePlannerprivate org.apache.http.conn.SchemePortResolverschemePortResolverprivate javax.net.ssl.SSLContextsslcontextprivate SchemeIOSessionStrategysslStrategyprivate booleansystemPropertiesprivate org.apache.http.client.AuthenticationStrategytargetAuthStrategyprivate java.util.concurrent.ThreadFactorythreadFactoryprivate java.lang.StringuserAgentprivate org.apache.http.client.UserTokenHandleruserTokenHandler
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpAsyncClientBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HttpAsyncClientBuilderaddInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)Adds this protocol interceptor to the head of the protocol processing list.HttpAsyncClientBuilderaddInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)Adds this protocol interceptor to the tail of the protocol processing list.HttpAsyncClientBuilderaddInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)Adds this protocol interceptor to the tail of the protocol processing list.CloseableHttpAsyncClientbuild()static HttpAsyncClientBuildercreate()HttpAsyncClientBuilderdisableAuthCaching()Disables authentication scheme caching.HttpAsyncClientBuilderdisableConnectionState()Disables connection state tracking.HttpAsyncClientBuilderdisableCookieManagement()Disables state (cookie) management.HttpAsyncClientBuildersetConnectionManager(NHttpClientConnectionManager connManager)AssignsNHttpClientConnectionManagerinstance.HttpAsyncClientBuildersetConnectionManagerShared(boolean shared)Defines the connection manager is to be shared by multiple client instances.HttpAsyncClientBuildersetConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)AssignsConnectionReuseStrategyinstance.HttpAsyncClientBuildersetDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)Assigns defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)Assigns defaultConnectionConfig.HttpAsyncClientBuildersetDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)Assigns defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)Assigns defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)Assigns defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)Assigns default request header values.HttpAsyncClientBuildersetDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)Assigns defaultIOReactorConfig.HttpAsyncClientBuildersetDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)Assigns defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.HttpAsyncClientBuildersetEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)AssignsNHttpClientEventHandlerinstance.HttpAsyncClientBuildersetHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)Deprecated.HttpAsyncClientBuildersetHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)AssignsHttpProcessorinstance.HttpAsyncClientBuildersetKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)AssignsConnectionKeepAliveStrategyinstance.HttpAsyncClientBuildersetMaxConnPerRoute(int maxConnPerRoute)Assigns maximum connection per route value.HttpAsyncClientBuildersetMaxConnTotal(int maxConnTotal)Assigns maximum total connection value.HttpAsyncClientBuildersetProxy(org.apache.http.HttpHost proxy)Assigns default proxy value.HttpAsyncClientBuildersetProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)AssignsAuthenticationStrategyinstance for target host authentication.HttpAsyncClientBuildersetPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)Assigns file containing public suffix matcher.HttpAsyncClientBuildersetRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)AssignsRedirectStrategyinstance.HttpAsyncClientBuildersetRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)AssignsHttpRoutePlannerinstance.HttpAsyncClientBuildersetSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)AssignsSchemePortResolverinstance.HttpAsyncClientBuildersetSSLContext(javax.net.ssl.SSLContext sslcontext)AssignsSSLContextinstance.HttpAsyncClientBuildersetSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)AssignsHostnameVerifierinstance.HttpAsyncClientBuildersetSSLStrategy(SchemeIOSessionStrategy strategy)AssignsSchemeIOSessionStrategyinstance.HttpAsyncClientBuildersetTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)AssignsAuthenticationStrategyinstance for proxy authentication.HttpAsyncClientBuildersetThreadFactory(java.util.concurrent.ThreadFactory threadFactory)AssignsThreadFactoryinstance.HttpAsyncClientBuildersetUserAgent(java.lang.String userAgent)AssignsUser-Agentvalue.HttpAsyncClientBuildersetUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)AssignsUserTokenHandlerinstance.private static java.lang.String[]split(java.lang.String s)HttpAsyncClientBuilderuseSystemProperties()Use system properties when creating and configuring default implementations.
-
-
-
Field Detail
-
connManager
private NHttpClientConnectionManager connManager
-
connManagerShared
private boolean connManagerShared
-
schemePortResolver
private org.apache.http.conn.SchemePortResolver schemePortResolver
-
sslStrategy
private SchemeIOSessionStrategy sslStrategy
-
hostnameVerifier
private javax.net.ssl.HostnameVerifier hostnameVerifier
-
sslcontext
private javax.net.ssl.SSLContext sslcontext
-
reuseStrategy
private org.apache.http.ConnectionReuseStrategy reuseStrategy
-
keepAliveStrategy
private org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy
-
targetAuthStrategy
private org.apache.http.client.AuthenticationStrategy targetAuthStrategy
-
proxyAuthStrategy
private org.apache.http.client.AuthenticationStrategy proxyAuthStrategy
-
userTokenHandler
private org.apache.http.client.UserTokenHandler userTokenHandler
-
httpprocessor
private org.apache.http.protocol.HttpProcessor httpprocessor
-
requestFirst
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor> requestFirst
-
requestLast
private java.util.LinkedList<org.apache.http.HttpRequestInterceptor> requestLast
-
responseFirst
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor> responseFirst
-
responseLast
private java.util.LinkedList<org.apache.http.HttpResponseInterceptor> responseLast
-
routePlanner
private org.apache.http.conn.routing.HttpRoutePlanner routePlanner
-
redirectStrategy
private org.apache.http.client.RedirectStrategy redirectStrategy
-
authSchemeRegistry
private org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry
-
cookieSpecRegistry
private org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry
-
cookieStore
private org.apache.http.client.CookieStore cookieStore
-
credentialsProvider
private org.apache.http.client.CredentialsProvider credentialsProvider
-
userAgent
private java.lang.String userAgent
-
proxy
private org.apache.http.HttpHost proxy
-
defaultHeaders
private java.util.Collection<? extends org.apache.http.Header> defaultHeaders
-
defaultIOReactorConfig
private org.apache.http.impl.nio.reactor.IOReactorConfig defaultIOReactorConfig
-
defaultConnectionConfig
private org.apache.http.config.ConnectionConfig defaultConnectionConfig
-
defaultRequestConfig
private org.apache.http.client.config.RequestConfig defaultRequestConfig
-
threadFactory
private java.util.concurrent.ThreadFactory threadFactory
-
eventHandler
private org.apache.http.nio.NHttpClientEventHandler eventHandler
-
publicSuffixMatcher
private org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher
-
systemProperties
private boolean systemProperties
-
cookieManagementDisabled
private boolean cookieManagementDisabled
-
authCachingDisabled
private boolean authCachingDisabled
-
connectionStateDisabled
private boolean connectionStateDisabled
-
maxConnTotal
private int maxConnTotal
-
maxConnPerRoute
private int maxConnPerRoute
-
-
Method Detail
-
create
public static HttpAsyncClientBuilder create()
-
setPublicSuffixMatcher
public final HttpAsyncClientBuilder setPublicSuffixMatcher(org.apache.http.conn.util.PublicSuffixMatcher publicSuffixMatcher)
Assigns file containing public suffix matcher. Instances of this class can be created withPublicSuffixMatcherLoader.- Since:
- 4.1
- See Also:
PublicSuffixMatcher,PublicSuffixMatcherLoader
-
setConnectionManager
public final HttpAsyncClientBuilder setConnectionManager(NHttpClientConnectionManager connManager)
AssignsNHttpClientConnectionManagerinstance.
-
setConnectionManagerShared
public final HttpAsyncClientBuilder setConnectionManagerShared(boolean shared)
Defines the connection manager is to be shared by multiple client instances.If the connection manager is shared its life-cycle is expected to be managed by the caller and it will not be shut down if the client is closed.
- Parameters:
shared- defines whether or not the connection manager can be shared by multiple clients.- Since:
- 4.1
-
setSchemePortResolver
public final HttpAsyncClientBuilder setSchemePortResolver(org.apache.http.conn.SchemePortResolver schemePortResolver)
AssignsSchemePortResolverinstance.
-
setMaxConnTotal
public final HttpAsyncClientBuilder setMaxConnTotal(int maxConnTotal)
Assigns maximum total connection value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setMaxConnPerRoute
public final HttpAsyncClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
Assigns maximum connection per route value.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setConnectionReuseStrategy
public final HttpAsyncClientBuilder setConnectionReuseStrategy(org.apache.http.ConnectionReuseStrategy reuseStrategy)
AssignsConnectionReuseStrategyinstance.
-
setKeepAliveStrategy
public final HttpAsyncClientBuilder setKeepAliveStrategy(org.apache.http.conn.ConnectionKeepAliveStrategy keepAliveStrategy)
AssignsConnectionKeepAliveStrategyinstance.
-
setUserTokenHandler
public final HttpAsyncClientBuilder setUserTokenHandler(org.apache.http.client.UserTokenHandler userTokenHandler)
AssignsUserTokenHandlerinstance.Please note this value can be overridden by the
disableConnectionState()method.
-
setTargetAuthenticationStrategy
public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy targetAuthStrategy)
AssignsAuthenticationStrategyinstance for proxy authentication.
-
setProxyAuthenticationStrategy
public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(org.apache.http.client.AuthenticationStrategy proxyAuthStrategy)
AssignsAuthenticationStrategyinstance for target host authentication.
-
setHttpProcessor
public final HttpAsyncClientBuilder setHttpProcessor(org.apache.http.protocol.HttpProcessor httpprocessor)
AssignsHttpProcessorinstance.
-
addInterceptorFirst
public final HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
addInterceptorLast
public final HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpResponseInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
addInterceptorFirst
public final HttpAsyncClientBuilder addInterceptorFirst(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the head of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
addInterceptorLast
public final HttpAsyncClientBuilder addInterceptorLast(org.apache.http.HttpRequestInterceptor itcp)
Adds this protocol interceptor to the tail of the protocol processing list.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
setRoutePlanner
public final HttpAsyncClientBuilder setRoutePlanner(org.apache.http.conn.routing.HttpRoutePlanner routePlanner)
AssignsHttpRoutePlannerinstance.
-
setRedirectStrategy
public final HttpAsyncClientBuilder setRedirectStrategy(org.apache.http.client.RedirectStrategy redirectStrategy)
AssignsRedirectStrategyinstance.
-
setDefaultCookieStore
public final HttpAsyncClientBuilder setDefaultCookieStore(org.apache.http.client.CookieStore cookieStore)
Assigns defaultCookieStoreinstance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCredentialsProvider
public final HttpAsyncClientBuilder setDefaultCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
Assigns defaultCredentialsProviderinstance which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultAuthSchemeRegistry
public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authSchemeRegistry)
Assigns defaultAuthSchemeregistry which will be used for request execution if not explicitly set in the client execution context.
-
setDefaultCookieSpecRegistry
public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(org.apache.http.config.Lookup<org.apache.http.cookie.CookieSpecProvider> cookieSpecRegistry)
Assigns defaultCookieSpecregistry which will be used for request execution if not explicitly set in the client execution context.
-
setUserAgent
public final HttpAsyncClientBuilder setUserAgent(java.lang.String userAgent)
AssignsUser-Agentvalue.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
setProxy
public final HttpAsyncClientBuilder setProxy(org.apache.http.HttpHost proxy)
Assigns default proxy value.Please note this value can be overridden by the
setRoutePlanner( org.apache.http.conn.routing.HttpRoutePlanner)method.
-
setSSLStrategy
public final HttpAsyncClientBuilder setSSLStrategy(SchemeIOSessionStrategy strategy)
AssignsSchemeIOSessionStrategyinstance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setSSLContext
public final HttpAsyncClientBuilder setSSLContext(javax.net.ssl.SSLContext sslcontext)
AssignsSSLContextinstance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)methods.
-
setHostnameVerifier
@Deprecated public final HttpAsyncClientBuilder setHostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier hostnameVerifier)
Deprecated.AssignsX509HostnameVerifierinstance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)methods.
-
setSSLHostnameVerifier
public final HttpAsyncClientBuilder setSSLHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
AssignsHostnameVerifierinstance.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)and thesetSSLStrategy( org.apache.http.nio.conn.SchemeIOSessionStrategy)methods.- Since:
- 4.1
-
setDefaultHeaders
public final HttpAsyncClientBuilder setDefaultHeaders(java.util.Collection<? extends org.apache.http.Header> defaultHeaders)
Assigns default request header values.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
setDefaultIOReactorConfig
public final HttpAsyncClientBuilder setDefaultIOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig config)
Assigns defaultIOReactorConfig.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setDefaultConnectionConfig
public final HttpAsyncClientBuilder setDefaultConnectionConfig(org.apache.http.config.ConnectionConfig config)
Assigns defaultConnectionConfig.Please note this value can be overridden by the
setConnectionManager( org.apache.http.nio.conn.NHttpClientConnectionManager)method.
-
setDefaultRequestConfig
public final HttpAsyncClientBuilder setDefaultRequestConfig(org.apache.http.client.config.RequestConfig config)
Assigns defaultRequestConfiginstance which will be used for request execution if not explicitly set in the client execution context.
-
setThreadFactory
public final HttpAsyncClientBuilder setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
AssignsThreadFactoryinstance.
-
setEventHandler
public final HttpAsyncClientBuilder setEventHandler(org.apache.http.nio.NHttpClientEventHandler eventHandler)
AssignsNHttpClientEventHandlerinstance.- Since:
- 4.1
-
disableConnectionState
public final HttpAsyncClientBuilder disableConnectionState()
Disables connection state tracking.
-
disableCookieManagement
public final HttpAsyncClientBuilder disableCookieManagement()
Disables state (cookie) management.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
disableAuthCaching
public final HttpAsyncClientBuilder disableAuthCaching()
Disables authentication scheme caching.Please note this value can be overridden by the
setHttpProcessor( org.apache.http.protocol.HttpProcessor)method.
-
useSystemProperties
public final HttpAsyncClientBuilder useSystemProperties()
Use system properties when creating and configuring default implementations.
-
split
private static java.lang.String[] split(java.lang.String s)
-
build
public CloseableHttpAsyncClient build()
-
-