Search in sources :

Example 1 with ClientConnectionManagerFactory

use of org.apache.http.conn.ClientConnectionManagerFactory in project platform_external_apache-http by android.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Example 2 with ClientConnectionManagerFactory

use of org.apache.http.conn.ClientConnectionManagerFactory in project XobotOS by xamarin.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Example 3 with ClientConnectionManagerFactory

use of org.apache.http.conn.ClientConnectionManagerFactory in project robovm by robovm.

the class DefaultHttpClient method createClientConnectionManager.

@Override
protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager connManager = null;
    HttpParams params = getParams();
    ClientConnectionManagerFactory factory = null;
    // Try first getting the factory directly as an object.
    factory = (ClientConnectionManagerFactory) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
    if (factory == null) {
        // then try getting its class name.
        String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
        if (className != null) {
            try {
                Class<?> clazz = Class.forName(className);
                factory = (ClientConnectionManagerFactory) clazz.newInstance();
            } catch (ClassNotFoundException ex) {
                throw new IllegalStateException("Invalid class name: " + className);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InstantiationException ex) {
                throw new InstantiationError(ex.getMessage());
            }
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(getParams(), registry);
    }
    return connManager;
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) ClientConnectionManager(org.apache.http.conn.ClientConnectionManager) BasicHttpParams(org.apache.http.params.BasicHttpParams) HttpParams(org.apache.http.params.HttpParams) ClientConnectionManagerFactory(org.apache.http.conn.ClientConnectionManagerFactory) SingleClientConnManager(org.apache.http.impl.conn.SingleClientConnManager) AuthSchemeRegistry(org.apache.http.auth.AuthSchemeRegistry) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry)

Aggregations

AuthSchemeRegistry (org.apache.http.auth.AuthSchemeRegistry)3 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)3 ClientConnectionManagerFactory (org.apache.http.conn.ClientConnectionManagerFactory)3 Scheme (org.apache.http.conn.scheme.Scheme)3 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)3 SingleClientConnManager (org.apache.http.impl.conn.SingleClientConnManager)3 BasicHttpParams (org.apache.http.params.BasicHttpParams)3 HttpParams (org.apache.http.params.HttpParams)3