List of usage examples for org.apache.http.impl.conn SchemeRegistryFactory createDefault
public static SchemeRegistry createDefault()
From source file:com.amazonaws.http.ConnectionManagerFactory.java
public static PoolingClientConnectionManager createPoolingClientConnManager(ClientConfiguration config, HttpParams httpClientParams) {/*w w w. j av a 2s .c o m*/ PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault(), config.getConnectionTTL(), TimeUnit.MILLISECONDS); connectionManager.setDefaultMaxPerRoute(config.getMaxConnections()); connectionManager.setMaxTotal(config.getMaxConnections()); if (config.useReaper()) { IdleConnectionReaper.registerConnectionManager(connectionManager); } return connectionManager; }
From source file:com.terremark.AbstractCloudApiAuthTestBase.java
/** * TODO/*from www. j a v a 2 s . co m*/ * * @throws Exception If there is a problem authenticating using Cloud API auth. */ @BeforeClass public static void cloudApiAuth() throws Exception { ThreadSafeClientConnManager httpConnectionManager = new ThreadSafeClientConnManager( SchemeRegistryFactory.createDefault()); httpConnectionManager.setMaxTotal(10); httpConnectionManager.setDefaultMaxPerRoute(10); final PropertiesBuilder props = new PropertiesBuilder().setEndPoint(ENDPOINT_URL).setAccessKey(ACCESS_KEY) .setAPIVersion(VERSION).setContentType(CONTENT_TYPE).setPrivateKey(PRIVATE_KEY) .setHttpClient(new DefaultHttpClient(httpConnectionManager)); client = TerremarkFactory.getClient(props); }
From source file:com.amazonaws.services.dynamodbv2.http.ConnectionManagerFactory.java
public static PoolingClientConnectionManager createPoolingClientConnManager(ClientConfiguration config, HttpParams httpClientParams) {/*from w ww . j a va 2 s. c o m*/ PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault(), config.getConnectionTTL(), TimeUnit.MILLISECONDS, new DelegatingDnsResolver(config.getDnsResolver())); connectionManager.setDefaultMaxPerRoute(config.getMaxConnections()); connectionManager.setMaxTotal(config.getMaxConnections()); if (config.useReaper()) { IdleConnectionReaper.registerConnectionManager(connectionManager); } return connectionManager; }
From source file:org.jasig.schedassist.impl.caldav.SchemeRegistryProvider.java
/** * /*from w ww .j a va 2 s .c o m*/ * @see SchemeRegistryFactory#createDefault() * @param schemeName * @param port * @param useSsl * @return */ public static SchemeRegistry createSchemeRegistry(String schemeName, int port, boolean useSsl) { SchemeRegistry registry = SchemeRegistryFactory.createDefault(); if (useSsl) { registry.register(new Scheme(schemeName, port, SSLSocketFactory.getSocketFactory())); } else { registry.register(new Scheme(schemeName, port, PlainSocketFactory.getSocketFactory())); } return registry; }
From source file:com.almende.reaal.apachehttp.ApacheHttpClient.java
/** * Instantiates a new apache http client. * *//*from ww w .j a v a 2s . c o m*/ private ApacheHttpClient() { // Allow self-signed SSL certificates: final TrustStrategy trustStrategy = new TrustSelfSignedStrategy(); final X509HostnameVerifier hostnameVerifier = new AllowAllHostnameVerifier(); final SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault(); SSLSocketFactory sslSf; try { sslSf = new SSLSocketFactory(trustStrategy, hostnameVerifier); final Scheme https = new Scheme("https", 443, sslSf); schemeRegistry.register(https); } catch (Exception e) { LOG.warning("Couldn't init SSL socket, https not supported!"); } // Work with PoolingClientConnectionManager final ClientConnectionManager connection = new PoolingClientConnectionManager(schemeRegistry); // Provide eviction thread to clear out stale threads. new Thread(new Runnable() { @Override public void run() { try { while (true) { synchronized (this) { wait(5000); connection.closeExpiredConnections(); connection.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (final InterruptedException ex) { } } }).start(); // generate httpclient httpClient = new DefaultHttpClient(connection); final HttpParams params = httpClient.getParams(); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY); params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000); params.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); params.setParameter(CoreConnectionPNames.TCP_NODELAY, true); httpClient.setParams(params); }
From source file:com.almende.eve.transport.http.ApacheHttpClient.java
/** * Instantiates a new apache http client. * *//*from w w w .j a va 2 s .c om*/ private ApacheHttpClient() { // Allow self-signed SSL certificates: final TrustStrategy trustStrategy = new TrustSelfSignedStrategy(); final X509HostnameVerifier hostnameVerifier = new AllowAllHostnameVerifier(); final SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault(); SSLSocketFactory sslSf; try { sslSf = new SSLSocketFactory(trustStrategy, hostnameVerifier); final Scheme https = new Scheme("https", 443, sslSf); schemeRegistry.register(https); } catch (Exception e) { LOG.warning("Couldn't init SSL socket, https not supported!"); } // Work with PoolingClientConnectionManager final ClientConnectionManager connection = new PoolingClientConnectionManager(schemeRegistry); // Provide eviction thread to clear out stale threads. new Thread(new Runnable() { @Override public void run() { try { while (true) { synchronized (this) { wait(5000); connection.closeExpiredConnections(); connection.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (final InterruptedException ex) { } } }).start(); // generate httpclient httpClient = new DefaultHttpClient(connection); // Set cookie policy and persistent cookieStore try { httpClient.setCookieStore(new MyCookieStore()); } catch (final Exception e) { LOG.log(Level.WARNING, "Failed to initialize persistent cookieStore!", e); } final HttpParams params = httpClient.getParams(); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY); params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000); params.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); params.setParameter(CoreConnectionPNames.TCP_NODELAY, true); httpClient.setParams(params); }
From source file:edu.wisc.commons.httpclient.SchemeRegistryFactoryBean.java
@Override protected SchemeRegistry createInstance() throws Exception { //Create the registry final SchemeRegistry registry; if (extendDefault) { registry = SchemeRegistryFactory.createDefault(); } else {/* ww w . j a v a 2 s . c o m*/ registry = new SchemeRegistry(); } //Register additional schemes for (final Scheme scheme : schemes) { registry.register(scheme); } return registry; }
From source file:org.oss.bonita.utils.bonita.RestClient.java
public RestClient(String bonitaURI) { this.bonitaURI = bonitaURI; this.httpContext = new BasicHttpContext(); PoolingClientConnectionManager conMan = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault()); conMan.setMaxTotal(200);/*from ww w.j a v a 2 s . c o m*/ conMan.setDefaultMaxPerRoute(200); this.httpClient = new DefaultHttpClient(conMan); }
From source file:de.onyxbits.raccoon.gplay.PlayManager.java
/** * create a proxy client//from w w w . ja v a2 s. c om * * @return either a client or null if none is configured * @throws KeyManagementException * @throws NumberFormatException * if that port could not be parsed. * @throws NoSuchAlgorithmException */ private static HttpClient createProxyClient(PlayProfile profile) throws KeyManagementException, NoSuchAlgorithmException { if (profile.getProxyAddress() == null) { return null; } PoolingClientConnectionManager connManager = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault()); connManager.setMaxTotal(100); connManager.setDefaultMaxPerRoute(30); DefaultHttpClient client = new DefaultHttpClient(connManager); client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme()); HttpHost proxy = new HttpHost(profile.getProxyAddress(), profile.getProxyPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if (profile.getProxyUser() != null && profile.getProxyPassword() != null) { client.getCredentialsProvider().setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials(profile.getProxyUser(), profile.getProxyPassword())); } return client; }