private HttpClientConnectionManager createHttpClientConnectionManager ( ) { ConnectionSocketFactory socketFactory = PlainConnectionSocketFactory . getSocketFactory ( ) ; LayeredConnectionSocketFactory sslSocketFactory ; try { sslSocketFactory = new SSLConnectionSocketFactory ( SSLContext . getDefault ( ) , SSLConnectionSocketFactory . STRICT_HOSTNAME_VERIFIER ) ; } catch ( NoSuchAlgorithmException e ) { throw new BceClientException ( "Fail to create SSLConnectionSocketFactory" , e ) ; } Registry < ConnectionSocketFactory > registry = RegistryBuilder . < ConnectionSocketFactory > create ( ) . register ( Protocol . HTTP . toString ( ) , socketFactory ) . register ( Protocol . HTTPS . toString ( ) , sslSocketFactory ) . build ( ) ; PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager ( registry ) ; connectionManager . setDefaultMaxPerRoute ( this . config . getMaxConnections ( ) ) ; connectionManager . setDefaultSocketConfig ( SocketConfig . custom ( ) . setSoTimeout ( this . config . getSocketTimeoutInMillis ( ) ) . setTcpNoDelay ( true ) . build ( ) ) ; connectionManager . setMaxTotal ( this . config . getMaxConnections ( ) ) ; return connectionManager ; }
Create connection manager for http client .