Example usage for org.apache.http.conn ClientConnectionManager getSchemeRegistry

List of usage examples for org.apache.http.conn ClientConnectionManager getSchemeRegistry

Introduction

In this page you can find the example usage for org.apache.http.conn ClientConnectionManager getSchemeRegistry.

Prototype

SchemeRegistry getSchemeRegistry();

Source Link

Document

Obtains the scheme registry used by this manager.

Usage

From source file:org.mule.modules.quickbooks.api.AbstractQuickBooksClientOAuth.java

public static DefaultHttpClient getThreadSafeClient() {
    DefaultHttpClient client = new DefaultHttpClient();
    ClientConnectionManager mgr = client.getConnectionManager();
    HttpParams params = client.getParams();

    client = new DefaultHttpClient(new ThreadSafeClientConnManager(params, mgr.getSchemeRegistry()), params);
    client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        @Override/*from  w  w w .  jav a 2s . c  o m*/
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
            if (executionCount > 3) {
                LOGGER.warn("Maximum tries reached for client http pool ");
                return false;
            }
            if (exception instanceof org.apache.http.NoHttpResponseException) {
                LOGGER.warn("No response from server on " + executionCount + " call");
                return true;
            }
            return false;
        }
    });

    return client;
}

From source file:org.oscarehr.common.hl7.v2.oscar_to_oscar.SendingUtils.java

private static HttpClient getTrustAllHttpClient() {
    try {//w w w. j  a v a  2s  . c  om
        SSLContext sslContext = SSLContext.getInstance("TLS");
        TrustManager[] temp = new TrustManager[1];
        temp[0] = new CxfClientUtilsOld.TrustAllManager();
        sslContext.init(null, temp, null);

        SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext);
        sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

        HttpClient httpClient = new DefaultHttpClient();
        ClientConnectionManager connectionManager = httpClient.getConnectionManager();
        SchemeRegistry schemeRegistry = connectionManager.getSchemeRegistry();
        schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
        return (new DefaultHttpClient(connectionManager, httpClient.getParams()));
    } catch (Exception e) {
        logger.error("Unexpected error", e);
        return (null);
    }
}

From source file:org.wso2.carbon.registry.es.utils.EmailUtil.java

/**
 * Initializes the httpClient./*from   ww  w . ja va2 s  . c  o m*/
 */
public static void initialize() throws XPathExpressionException {

    DefaultHttpClient client = new DefaultHttpClient();

    HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
    SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
    Scheme sch = new Scheme("https", 443, socketFactory);
    ClientConnectionManager mgr = client.getConnectionManager();
    mgr.getSchemeRegistry().register(sch);
    httpClient = new DefaultHttpClient(mgr, client.getParams());

    // Set verifier
    HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
}