List of usage examples for org.apache.http.nio.conn.ssl SSLIOSessionStrategy getSystemDefaultStrategy
public static SSLIOSessionStrategy getSystemDefaultStrategy()
From source file:org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitFactory.java
public synchronized void setupNIOClient(HTTPClientPolicy clientPolicy) throws IOReactorException { if (client != null) { return;/* w ww. ja v a 2s. co m*/ } IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(ioThreadCount) .setSelectInterval(selectInterval).setInterestOpQueued(interestOpQueued).setSoLinger(soLinger) .setSoTimeout(soTimeout).setSoKeepAlive(soKeepalive).setTcpNoDelay(tcpNoDelay).build(); Registry<SchemeIOSessionStrategy> ioSessionFactoryRegistry = RegistryBuilder .<SchemeIOSessionStrategy>create().register("http", NoopIOSessionStrategy.INSTANCE) .register("https", SSLIOSessionStrategy.getSystemDefaultStrategy()).build(); ManagedNHttpClientConnectionFactory connectionFactory = new ManagedNHttpClientConnectionFactory() { @Override public ManagedNHttpClientConnection create(final IOSession iosession, final ConnectionConfig config) { ManagedNHttpClientConnection conn = super.create(iosession, config); return conn; } }; DefaultConnectingIOReactor ioreactor = new DefaultConnectingIOReactor(config); connectionManager = new PoolingNHttpClientConnectionManager(ioreactor, connectionFactory, ioSessionFactoryRegistry, DefaultSchemePortResolver.INSTANCE, SystemDefaultDnsResolver.INSTANCE, connectionTTL, TimeUnit.MILLISECONDS); connectionManager.setDefaultMaxPerRoute(maxPerRoute); connectionManager.setMaxTotal(maxConnections); ConnectionConfig connectionConfig = ConnectionConfig.custom() .setBufferSize(clientPolicy.getChunkLength() > 0 ? clientPolicy.getChunkLength() : 16332).build(); connectionManager.setDefaultConnectionConfig(connectionConfig); RedirectStrategy redirectStrategy = new RedirectStrategy() { public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException { return false; } public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException { return null; } }; HttpAsyncClientBuilder httpAsyncClientBuilder = HttpAsyncClients.custom() .setConnectionManager(connectionManager).setRedirectStrategy(redirectStrategy) .setDefaultCookieStore(new BasicCookieStore() { private static final long serialVersionUID = 1L; public void addCookie(Cookie cookie) { } }); adaptClientBuilder(httpAsyncClientBuilder); client = httpAsyncClientBuilder.build(); // Start the client thread client.start(); if (this.connectionTTL == 0) { //if the connection does not have an expiry deadline //use the ConnectionMaxIdle to close the idle connection new CloseIdleConnectionThread(connectionManager, client).start(); } }