Java 类org.apache.http.conn.params.ConnPerRoute 实例源码

项目:lams    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        int maxTotalConnections,
        long connTTL,
        final TimeUnit connTTLTimeUnit) {
    super();
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    if (connPerRoute == null) {
        throw new IllegalArgumentException("Connections per route may not be null");
    }
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routeToPool     = createRouteToPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        final int maxTotalConnections,
        final long connTTL,
        final TimeUnit connTTLTimeUnit) {
    super();
    Args.notNull(operator, "Connection operator");
    Args.notNull(connPerRoute, "Connections per route");
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routeToPool     = createRouteToPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:galaxy-sdk-java    文件:EMQClientFactory.java   
public static HttpClient generateHttpClient(final int maxTotalConnections,
    final int maxTotalConnectionsPerRoute, int connTimeout) {
  HttpParams params = new BasicHttpParams();
  ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections);
  ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
    @Override
    public int getMaxForRoute(HttpRoute route) {
      return maxTotalConnectionsPerRoute;
    }
  });
  HttpConnectionParams
      .setConnectionTimeout(params, connTimeout);
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(
      new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
  sslSocketFactory.setHostnameVerifier(SSLSocketFactory.
      ALLOW_ALL_HOSTNAME_VERIFIER);
  schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
  ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params,
      schemeRegistry);
  return new DefaultHttpClient(conMgr, params);
}
项目:galaxy-sdk-java    文件:ClientFactory.java   
public static HttpClient generateHttpClient(final int maxTotalConnections,
                                            final int maxTotalConnectionsPerRoute, int connTimeout) {
  HttpParams params = new BasicHttpParams();
  ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections);
  ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
    @Override
    public int getMaxForRoute(HttpRoute route) {
      return maxTotalConnectionsPerRoute;
    }
  });
  HttpConnectionParams
      .setConnectionTimeout(params, connTimeout);
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(
      new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
  sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
  ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schemeRegistry);
  return new DefaultHttpClient(conMgr, params);
}
项目:galaxy-sdk-java    文件:MetricsClientFactory.java   
public static HttpClient generateHttpClient(final int maxTotalConnections,
    final int maxTotalConnectionsPerRoute, int connTimeout) {
  HttpParams params = new BasicHttpParams();
  ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections);
  ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
    @Override
    public int getMaxForRoute(HttpRoute route) {
      return maxTotalConnectionsPerRoute;
    }
  });
  HttpConnectionParams
      .setConnectionTimeout(params, connTimeout);
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(
      new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
  sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
  ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schemeRegistry);
  return new DefaultHttpClient(conMgr, params);
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        int maxTotalConnections) {
    this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS);
}
项目:lams    文件:RouteSpecificPool.java   
/**
 * Creates a new route-specific pool.
 *
 * @param route the route for which to pool
 * @param connPerRoute the connections per route configuration
 */
public RouteSpecificPool(HttpRoute route, ConnPerRoute connPerRoute) {
    this.route = route;
    this.connPerRoute = connPerRoute;
    this.maxEntries = connPerRoute.getMaxForRoute(route);
    this.freeEntries = new LinkedList<BasicPoolEntry>();
    this.waitingThreads = new LinkedList<WaitingThread>();
    this.numEntries = 0;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool, managed by route.
 *
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionOperator operator,
        final ConnPerRoute connPerRoute,
        final int maxTotalConnections) {
    this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS);
}
项目:purecloud-iot    文件:RouteSpecificPool.java   
/**
 * @deprecated (4.1)  use {@link RouteSpecificPool#RouteSpecificPool(HttpRoute, ConnPerRoute)}
 */
@Deprecated
public RouteSpecificPool(final HttpRoute route, final int maxEntries) {
    this.route = route;
    this.maxEntries = maxEntries;
    this.connPerRoute = new ConnPerRoute() {
        @Override
        public int getMaxForRoute(final HttpRoute unused) {
            return RouteSpecificPool.this.maxEntries;
        }
    };
    this.freeEntries = new LinkedList<BasicPoolEntry>();
    this.waitingThreads = new LinkedList<WaitingThread>();
    this.numEntries = 0;
}
项目:purecloud-iot    文件:RouteSpecificPool.java   
/**
 * Creates a new route-specific pool.
 *
 * @param route the route for which to pool
 * @param connPerRoute the connections per route configuration
 */
public RouteSpecificPool(final HttpRoute route, final ConnPerRoute connPerRoute) {
    this.route = route;
    this.connPerRoute = connPerRoute;
    this.maxEntries = connPerRoute.getMaxForRoute(route);
    this.freeEntries = new LinkedList<BasicPoolEntry>();
    this.waitingThreads = new LinkedList<WaitingThread>();
    this.numEntries = 0;
}
项目:AntennaPodSP    文件:AntennapodHttpClient.java   
private static ClientConnectionManager createClientConnectionManager() {
    HttpParams params = new BasicHttpParams();
    params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, MAX_CONNECTIONS);
    params.setParameter(ConnManagerParams.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() {
        @Override
        public int getMaxForRoute(HttpRoute httpRoute) {
            return MAX_CONNECTIONS_PER_ROUTE;
        }
    });
    return new ThreadSafeClientConnManager(params, prepareSchemeRegistry());
}
项目:SoundcloudAPI    文件:ApiWrapper.java   
/**
 * @return the default HttpParams
 * @see <a href="http://developer.android.com/reference/android/net/http/AndroidHttpClient.html#newInstance(java.lang.String, android.content.Context)">
 *      android.net.http.AndroidHttpClient#newInstance(String, Context)</a>
 */
protected HttpParams getParams() {
    final HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT);
    HttpConnectionParams.setSocketBufferSize(params, BUFFER_SIZE);
    ConnManagerParams.setMaxTotalConnections(params, MAX_TOTAL_CONNECTIONS);

    // Turn off stale checking.  Our connections break all the time anyway,
    // and it's not worth it to pay the penalty of checking every time.
    HttpConnectionParams.setStaleCheckingEnabled(params, false);

    // fix contributed by Bjorn Roche XXX check if still needed
    params.setBooleanParameter("http.protocol.expect-continue", false);
    params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() {
        @Override
        public int getMaxForRoute(HttpRoute httpRoute) {
            if (env.isApiHost(httpRoute.getTargetHost())) {
                // there will be a lot of concurrent request to the API host
                return MAX_TOTAL_CONNECTIONS;
            } else {
                return ConnPerRouteBean.DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
            }
        }
    });
    // apply system proxy settings
    final String proxyHost = System.getProperty("http.proxyHost");
    final String proxyPort = System.getProperty("http.proxyPort");
    if (proxyHost != null) {
        int port = 80;
        try {
            port = Integer.parseInt(proxyPort);
        } catch (NumberFormatException ignored) {
        }
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, port));
    }
    return params;
}
项目:paperchains    文件:ApiWrapper.java   
/**
 * @return the default HttpParams
 * @see <a href="http://developer.android.com/reference/android/net/http/AndroidHttpClient.html#newInstance(java.lang.String, android.content.Context)">
 *      android.net.http.AndroidHttpClient#newInstance(String, Context)</a>
 */
protected HttpParams getParams() {
    final HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT);
    HttpConnectionParams.setSocketBufferSize(params, BUFFER_SIZE);
    ConnManagerParams.setMaxTotalConnections(params, MAX_TOTAL_CONNECTIONS);

    // Turn off stale checking.  Our connections break all the time anyway,
    // and it's not worth it to pay the penalty of checking every time.
    HttpConnectionParams.setStaleCheckingEnabled(params, false);

    // fix contributed by Bjorn Roche XXX check if still needed
    params.setBooleanParameter("http.protocol.expect-continue", false);
    params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() {
        @Override
        public int getMaxForRoute(HttpRoute httpRoute) {
            if (env.isApiHost(httpRoute.getTargetHost())) {
                // there will be a lot of concurrent request to the API host
                return MAX_TOTAL_CONNECTIONS;
            } else {
                return ConnPerRouteBean.DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
            }
        }
    });
    // apply system proxy settings
    final String proxyHost = System.getProperty("http.proxyHost");
    final String proxyPort = System.getProperty("http.proxyPort");
    if (proxyHost != null) {
        int port = 80;
        try {
            port = Integer.parseInt(proxyPort);
        } catch (NumberFormatException ignored) {
        }
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, port));
    }
    return params;
}
项目:EinschlafenPodcastAndroidApp    文件:AntennapodHttpClient.java   
private static ClientConnectionManager createClientConnectionManager() {
    HttpParams params = new BasicHttpParams();
    params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, MAX_CONNECTIONS);
    params.setParameter(ConnManagerParams.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() {
        @Override
        public int getMaxForRoute(HttpRoute httpRoute) {
            return MAX_CONNECTIONS_PER_ROUTE;
        }
    });
    return new ThreadSafeClientConnManager(params, prepareSchemeRegistry());
}
项目:SecureShareLib    文件:ApiWrapper.java   
/**
 * @return the default HttpParams
 * @see <a href="http://developer.android.com/reference/android/net/http/AndroidHttpClient.html#newInstance(java.lang.String, android.content.Context)">
 *      android.net.http.AndroidHttpClient#newInstance(String, Context)</a>
 */
protected HttpParams getParams() {
    final HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT);
    HttpConnectionParams.setSocketBufferSize(params, BUFFER_SIZE);
    ConnManagerParams.setMaxTotalConnections(params, MAX_TOTAL_CONNECTIONS);

    // Turn off stale checking.  Our connections break all the time anyway,
    // and it's not worth it to pay the penalty of checking every time.
    HttpConnectionParams.setStaleCheckingEnabled(params, false);

    // fix contributed by Bjorn Roche XXX check if still needed
    params.setBooleanParameter("http.protocol.expect-continue", false);
    params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() {
        @Override
        public int getMaxForRoute(HttpRoute httpRoute) {
            if (env.isApiHost(httpRoute.getTargetHost())) {
                // there will be a lot of concurrent request to the API host
                return MAX_TOTAL_CONNECTIONS;
            } else {
                return ConnPerRouteBean.DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
            }
        }
    });
    // apply system proxy settings
    final String proxyHost = System.getProperty("http.proxyHost");
    final String proxyPort = System.getProperty("http.proxyPort");
    if (proxyHost != null) {
        int port = 80;
        try {
            port = Integer.parseInt(proxyPort);
        } catch (NumberFormatException ignored) {
        }
        params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost(proxyHost, port));
    }
    return params;
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name, ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL,
        TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name, ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections) {
    super(operator, connPerRoute, maxTotalConnections);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL,
        TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionOperator operator,
        ConnPerRoute connPerRoute, int maxTotalConnections) {
    super(operator, connPerRoute, maxTotalConnections);
}
项目:cougar    文件:CougarClientConnManager.java   
private CougarConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute,
                              int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) {
    super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit);
}
项目:asianet-autologin    文件:HttpManager.java   
private HttpManager(Boolean debug, String version) {
    // Set basic data
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "UTF-8");
    HttpProtocolParams.setUseExpectContinue(params, true);
    HttpProtocolParams.setUserAgent(params, HttpUtils.userAgent);

    // Make pool
    ConnPerRoute connPerRoute = new ConnPerRouteBean(12);
    ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
    ConnManagerParams.setMaxTotalConnections(params, 20);

    // Set timeout
    HttpConnectionParams.setStaleCheckingEnabled(params, false);
    HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
    HttpConnectionParams.setSoTimeout(params, 20 * 1000);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // Some client params
    HttpClientParams.setRedirecting(params, false);

    // Register http/s schemas!
    SchemeRegistry schReg = new SchemeRegistry();
    schReg.register(new Scheme("http", PlainSocketFactory
            .getSocketFactory(), 80));

    if (debug) {
        // Install the all-trusting trust manager
        // Create a trust manager that does not validate certificate chains
        TrustManager[] trustManagers = new X509TrustManager[1];
        trustManagers[0] = new TrustAllManager();

        try {
            SSLContext sc = SSLContext.getInstance("SSL");
            sc.init(null, trustManagers, null);
            schReg.register(new Scheme("https", (SocketFactory) sc
                    .getSocketFactory(), 443));
        } catch (Exception e) {
            ;
        }
    } else {
        schReg.register(new Scheme("https", SSLSocketFactory
                .getSocketFactory(), 443));

    }
    ClientConnectionManager conMgr = new ThreadSafeClientConnManager(
            params, schReg);
    client = new DefaultHttpClient(conMgr, params);

}
项目:ks3-sdk-java    文件:HttpFactory.java   
public HttpClient getHttpClient() {
      HttpParams params = new BasicHttpParams();
      HttpProtocolParams.setUseExpectContinue(params, false);
      HttpProtocolParams.setUserAgent(params, ConnectioinConfig.userAgent);
      ConnManagerParams.setMaxTotalConnections(params, ConnectioinConfig.maxConnections);
      ConnManagerParams.setMaxConnectionsPerRoute(params,
              new ConnPerRoute() {
                  @Override
                  public int getMaxForRoute(HttpRoute httproute) {
                      return 32;
                  }
              });

      HttpClientParams.setRedirecting(params, true);

      params.setParameter(
              CoreConnectionPNames.CONNECTION_TIMEOUT, ConnectioinConfig.connectionTimeout);
      params.setParameter(CoreConnectionPNames.SO_TIMEOUT,
              ConnectioinConfig.socketTimeout);
      params.setParameter(
              CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024);

      params.setParameter(ClientPNames.HANDLE_REDIRECTS,
              Boolean.FALSE);
      params.setParameter(
              CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8"); // 默认为ISO-8859-1
      params.setParameter(
              CoreProtocolPNames.HTTP_ELEMENT_CHARSET, "UTF-8"); // 默认为US-ASCII
      params.removeParameter(ConnRouteParams.DEFAULT_PROXY);

      SchemeRegistry schReg = new SchemeRegistry();
      schReg.register(new Scheme("http", PlainSocketFactory
              .getSocketFactory(), 80));
      schReg.register(new Scheme("https", SSLSocketFactory
              .getSocketFactory(), 443));
      ThreadSafeClientConnManager conMgr = new ThreadSafeClientConnManager(
              params, schReg);

      DefaultHttpClient client = new DefaultHttpClient(conMgr, params);


      //Auto retry.
      client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {

    @Override
    public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {

        if(executionCount > ConnectioinConfig.maxRetryCount)
             return false;

        if(exception instanceof NoHttpResponseException)
            return true; 

        if(exception instanceof SocketTimeoutException)
            return true;

        return false;
    }
});

      return client;
  }
项目:OyVer    文件:CustomHTTPClient.java   
/**
 * Get a singleton, thread-safe HttpClient for making HTTP requests.
 */
public static synchronized HttpClient getHttpClient() {
    if (customHttpClient == null) {
        final HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
        HttpProtocolParams.setUseExpectContinue(params, false);

        ConnManagerParams.setTimeout(params, 100);

        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);

        final SchemeRegistry schReg = new SchemeRegistry();
        schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));


        ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
            @Override
            public int getMaxForRoute(final HttpRoute httproute)
            {
                return 20;
            }
        });

        final ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params,schReg);

        customHttpClient = new DefaultHttpClient(conMgr, params);
        requestRetryHandler = new DefaultHttpRequestRetryHandler(5, false){

            @Override
            public boolean retryRequest(IOException ex, int count, HttpContext cx) {
                if(super.retryRequest(ex, count, cx)){
                    Log.d(TAG, "Retrying request " + cx.toString());
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    return true;
                }
                else{
                    return false;
                }
            }
        };

        customHttpClient.setHttpRequestRetryHandler(requestRetryHandler);
    }
    return customHttpClient;
}
项目:TurkcellUpdater_android_sdk    文件:Utilities.java   
static DefaultHttpClient createClient(String userAgent,
        boolean acceptAllSslCertificates) {

    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setStaleCheckingEnabled(params, false);
    HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);

    // to make connection pool more fault tolerant
    ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
        public int getMaxForRoute(HttpRoute route) {
            return 10;
        }
    });

    HttpConnectionParams.setSoTimeout(params, 20 * 1000);

    HttpConnectionParams.setSocketBufferSize(params, 8192);

    HttpClientParams.setRedirecting(params, false);

    HttpProtocolParams.setUserAgent(params, userAgent);

    SSLSocketFactory sslSocketFactory = null;

    if (acceptAllSslCertificates) {
        try {
            sslSocketFactory = new AcceptAllSocketFactory();
        } catch (Exception e) {
            // omitted
        }
    }

    if (sslSocketFactory == null) {
        sslSocketFactory = SSLSocketFactory.getSocketFactory();
    }

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory
            .getSocketFactory(), 80));
    schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));

    ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(
            params, schemeRegistry);

    final DefaultHttpClient client = new DefaultHttpClient(manager, params);

    return client;
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
/**
 * Creates a new route-specific pool.
 * Called by {@link #getRoutePool} when necessary.
 *
 * @param route     the route
 *
 * @return  the new pool
 */
protected RouteSpecificPool newRouteSpecificPool(HttpRoute route) {
    ConnPerRoute connPerRoute = ConnManagerParams.getMaxConnectionsPerRoute(params);
    return new RouteSpecificPool(route, connPerRoute.getMaxForRoute(route));
}