com.ning.http.client
Class AsyncHttpClientConfig

java.lang.Object
  extended by com.ning.http.client.AsyncHttpClientConfig
Direct Known Subclasses:
AsyncHttpClientConfigBean

public class AsyncHttpClientConfig
extends Object

Configuration class to use with a AsyncHttpClient. System property can be also used to configure this object default behavior by doing:

-Dcom.ning.http.client.AsyncHttpClientConfig.nameOfTheProperty ex:

-Dcom.ning.http.client.AsyncHttpClientConfig.defaultMaxTotalConnections -Dcom.ning.http.client.AsyncHttpClientConfig.defaultMaxTotalConnections -Dcom.ning.http.client.AsyncHttpClientConfig.defaultMaxConnectionsPerHost -Dcom.ning.http.client.AsyncHttpClientConfig.defaultConnectionTimeoutInMS -Dcom.ning.http.client.AsyncHttpClientConfig.defaultIdleConnectionInPoolTimeoutInMS -Dcom.ning.http.client.AsyncHttpClientConfig.defaultRequestTimeoutInMS -Dcom.ning.http.client.AsyncHttpClientConfig.defaultRedirectsEnabled -Dcom.ning.http.client.AsyncHttpClientConfig.defaultMaxRedirects


Nested Class Summary
static class AsyncHttpClientConfig.Builder
          Builder for an AsyncHttpClient
 
Field Summary
protected  boolean allowPoolingConnection
           
protected  boolean allowSslConnectionPool
           
protected  ExecutorService applicationThreadPool
           
protected static String ASYNC_CLIENT
           
protected  boolean compressionEnabled
           
protected  ConnectionsPool<?,?> connectionsPool
           
protected  int connectionTimeOutInMs
           
protected  HostnameVerifier hostnameVerifier
           
protected  int idleConnectionInPoolTimeoutInMs
           
protected  List<IOExceptionFilter> ioExceptionFilters
           
protected  int ioThreadMultiplier
           
protected  int maxConnectionPerHost
           
protected  int maxDefaultRedirects
           
protected  int maxRequestRetry
           
protected  int maxTotalConnections
           
protected  AsyncHttpProviderConfig<?,?> providerConfig
           
protected  ProxyServer proxyServer
           
protected  Realm realm
           
protected  ScheduledExecutorService reaper
           
protected  boolean redirectEnabled
           
protected  boolean removeQueryParamOnRedirect
           
protected  int requestCompressionLevel
           
protected  List<RequestFilter> requestFilters
           
protected  int requestTimeoutInMs
           
protected  List<ResponseFilter> responseFilters
           
protected  SSLContext sslContext
           
protected  SSLEngineFactory sslEngineFactory
           
protected  String userAgent
           
protected  boolean useRawUrl
           
 
Constructor Summary
protected AsyncHttpClientConfig()
           
 
Method Summary
 ExecutorService executorService()
          Return the ExecutorService an AsyncHttpClient use for handling asynchronous response.
 boolean getAllowPoolingConnection()
          Is the ConnectionsPool support enabled.
 AsyncHttpProviderConfig<?,?> getAsyncHttpProviderConfig()
          Return the AsyncHttpProviderConfig
 ConnectionsPool<?,?> getConnectionsPool()
          Return an instance of ConnectionsPool
 int getConnectionTimeoutInMs()
          Return the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host
 HostnameVerifier getHostnameVerifier()
          Return the HostnameVerifier
 int getIdleConnectionInPoolTimeoutInMs()
          Return the maximum time in millisecond an AsyncHttpClient will keep connection in pool.
 int getIdleConnectionTimeoutInMs()
          Deprecated. Please use getIdleConnectionInPoolTimeoutInMs()
 List<IOExceptionFilter> getIOExceptionFilters()
          Return the list of IOException
 int getIoThreadMultiplier()
           
 boolean getKeepAlive()
          Deprecated. - Use getAllowPoolingConnection()
 int getMaxConnectionPerHost()
          Return the maximum number of connections per hosts an AsyncHttpClient can handle.
 int getMaxRedirects()
          Get the maximum number of HTTP redirect
 int getMaxRequestRetry()
          Return the number of time the library will retry when an IOException is throw by the remote server
 int getMaxTotalConnections()
          Return the maximum number of connections an AsyncHttpClient can handle.
 ProxyServer getProxyServer()
          An instance of ProxyServer used by an AsyncHttpClient
 Realm getRealm()
          Return the current Realm}
 int getRequestCompressionLevel()
          Return the compression level, or -1 if no compression is used.
 List<RequestFilter> getRequestFilters()
          Return the list of RequestFilter
 int getRequestTimeoutInMs()
          Return the maximum time in millisecond an AsyncHttpClient wait for a response
 List<ResponseFilter> getResponseFilters()
          Return the list of ResponseFilter
 SSLContext getSSLContext()
          Return an instance of SSLContext used for SSL connection.
 SSLEngineFactory getSSLEngineFactory()
          Return an instance of SSLEngineFactory used for SSL connection.
 String getUserAgent()
          Return the USER_AGENT header value
 boolean isClosed()
          Return true if one of the ExecutorService has been shutdown.
 boolean isCompressionEnabled()
          Is HTTP compression enabled.
 boolean isRedirectEnabled()
          Is HTTP redirect enabled
 boolean isRemoveQueryParamOnRedirect()
          Return true if the query parameters will be stripped from the request when a redirect is requested.
 boolean isSslConnectionPoolEnabled()
          Return true is SSL connection polling is enabled.
 boolean isUseRawUrl()
           
 ScheduledExecutorService reaper()
          A ScheduledExecutorService used to expire idle connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASYNC_CLIENT

protected static final String ASYNC_CLIENT

maxTotalConnections

protected int maxTotalConnections

maxConnectionPerHost

protected int maxConnectionPerHost

connectionTimeOutInMs

protected int connectionTimeOutInMs

idleConnectionInPoolTimeoutInMs

protected int idleConnectionInPoolTimeoutInMs

requestTimeoutInMs

protected int requestTimeoutInMs

redirectEnabled

protected boolean redirectEnabled

maxDefaultRedirects

protected int maxDefaultRedirects

compressionEnabled

protected boolean compressionEnabled

userAgent

protected String userAgent

allowPoolingConnection

protected boolean allowPoolingConnection

reaper

protected ScheduledExecutorService reaper

applicationThreadPool

protected ExecutorService applicationThreadPool

proxyServer

protected ProxyServer proxyServer

sslContext

protected SSLContext sslContext

sslEngineFactory

protected SSLEngineFactory sslEngineFactory

providerConfig

protected AsyncHttpProviderConfig<?,?> providerConfig

connectionsPool

protected ConnectionsPool<?,?> connectionsPool

realm

protected Realm realm

requestFilters

protected List<RequestFilter> requestFilters

responseFilters

protected List<ResponseFilter> responseFilters

ioExceptionFilters

protected List<IOExceptionFilter> ioExceptionFilters

requestCompressionLevel

protected int requestCompressionLevel

maxRequestRetry

protected int maxRequestRetry

allowSslConnectionPool

protected boolean allowSslConnectionPool

useRawUrl

protected boolean useRawUrl

removeQueryParamOnRedirect

protected boolean removeQueryParamOnRedirect

hostnameVerifier

protected HostnameVerifier hostnameVerifier

ioThreadMultiplier

protected int ioThreadMultiplier
Constructor Detail

AsyncHttpClientConfig

protected AsyncHttpClientConfig()
Method Detail

reaper

public ScheduledExecutorService reaper()
A ScheduledExecutorService used to expire idle connections.

Returns:
ScheduledExecutorService

getMaxTotalConnections

public int getMaxTotalConnections()
Return the maximum number of connections an AsyncHttpClient can handle.

Returns:
the maximum number of connections an AsyncHttpClient can handle.

getMaxConnectionPerHost

public int getMaxConnectionPerHost()
Return the maximum number of connections per hosts an AsyncHttpClient can handle.

Returns:
the maximum number of connections per host an AsyncHttpClient can handle.

getConnectionTimeoutInMs

public int getConnectionTimeoutInMs()
Return the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host

Returns:
the maximum time in millisecond an AsyncHttpClient can wait when connecting to a remote host

getIdleConnectionTimeoutInMs

public int getIdleConnectionTimeoutInMs()
Deprecated. Please use getIdleConnectionInPoolTimeoutInMs()

Return the maximum time in millisecond an AsyncHttpClient can stay idle.

Returns:
the maximum time in millisecond an AsyncHttpClient can stay idle.

getIdleConnectionInPoolTimeoutInMs

public int getIdleConnectionInPoolTimeoutInMs()
Return the maximum time in millisecond an AsyncHttpClient will keep connection in pool.

Returns:
the maximum time in millisecond an AsyncHttpClient will keep connection in pool.

getRequestTimeoutInMs

public int getRequestTimeoutInMs()
Return the maximum time in millisecond an AsyncHttpClient wait for a response

Returns:
the maximum time in millisecond an AsyncHttpClient wait for a response

isRedirectEnabled

public boolean isRedirectEnabled()
Is HTTP redirect enabled

Returns:
true if enabled.

getMaxRedirects

public int getMaxRedirects()
Get the maximum number of HTTP redirect

Returns:
the maximum number of HTTP redirect

getAllowPoolingConnection

public boolean getAllowPoolingConnection()
Is the ConnectionsPool support enabled.

Returns:
true if keep-alive is enabled

getKeepAlive

public boolean getKeepAlive()
Deprecated. - Use getAllowPoolingConnection()

Is the ConnectionsPool support enabled.

Returns:
true if keep-alive is enabled

getUserAgent

public String getUserAgent()
Return the USER_AGENT header value

Returns:
the USER_AGENT header value

isCompressionEnabled

public boolean isCompressionEnabled()
Is HTTP compression enabled.

Returns:
true if compression is enabled

executorService

public ExecutorService executorService()
Return the ExecutorService an AsyncHttpClient use for handling asynchronous response.

Returns:
the ExecutorService an AsyncHttpClient use for handling asynchronous response.

getProxyServer

public ProxyServer getProxyServer()
An instance of ProxyServer used by an AsyncHttpClient

Returns:
instance of ProxyServer

getSSLContext

public SSLContext getSSLContext()
Return an instance of SSLContext used for SSL connection.

Returns:
an instance of SSLContext used for SSL connection.

getConnectionsPool

public ConnectionsPool<?,?> getConnectionsPool()
Return an instance of ConnectionsPool

Returns:
an instance of ConnectionsPool

getSSLEngineFactory

public SSLEngineFactory getSSLEngineFactory()
Return an instance of SSLEngineFactory used for SSL connection.

Returns:
an instance of SSLEngineFactory used for SSL connection.

getAsyncHttpProviderConfig

public AsyncHttpProviderConfig<?,?> getAsyncHttpProviderConfig()
Return the AsyncHttpProviderConfig

Returns:
the AsyncHttpProviderConfig

getRealm

public Realm getRealm()
Return the current Realm}

Returns:
the current Realm}

getRequestFilters

public List<RequestFilter> getRequestFilters()
Return the list of RequestFilter

Returns:
Unmodifiable list of ResponseFilter

getResponseFilters

public List<ResponseFilter> getResponseFilters()
Return the list of ResponseFilter

Returns:
Unmodifiable list of ResponseFilter

getIOExceptionFilters

public List<IOExceptionFilter> getIOExceptionFilters()
Return the list of IOException

Returns:
Unmodifiable list of IOException

getRequestCompressionLevel

public int getRequestCompressionLevel()
Return the compression level, or -1 if no compression is used.

Returns:
the compression level, or -1 if no compression is use

getMaxRequestRetry

public int getMaxRequestRetry()
Return the number of time the library will retry when an IOException is throw by the remote server

Returns:
the number of time the library will retry when an IOException is throw by the remote server

isSslConnectionPoolEnabled

public boolean isSslConnectionPoolEnabled()
Return true is SSL connection polling is enabled. Default is true.

Returns:
true is enabled.

isUseRawUrl

public boolean isUseRawUrl()
Returns:
the useRawUrl

isRemoveQueryParamOnRedirect

public boolean isRemoveQueryParamOnRedirect()
Return true if the query parameters will be stripped from the request when a redirect is requested.

Returns:
true if the query parameters will be stripped from the request when a redirect is requested.

isClosed

public boolean isClosed()
Return true if one of the ExecutorService has been shutdown.

Returns:
true if one of the ExecutorService has been shutdown.

getHostnameVerifier

public HostnameVerifier getHostnameVerifier()
Return the HostnameVerifier

Returns:
the HostnameVerifier

getIoThreadMultiplier

public int getIoThreadMultiplier()
Returns:
number to multiply by availableProcessors() that will determine # of NioWorkers to use


Copyright © 2011. All Rights Reserved.