Package org.apache.http.impl.conn

Examples of org.apache.http.impl.conn.PoolingClientConnectionManager


    public static HttpClient createCachingHttpClient() {
        return new SystemDefaultHttpClient() {
          /** See SystemDefaultHttpClient (4.2).  This version always sets the connection cache */ 
          @Override
          protected ClientConnectionManager createClientConnectionManager() {
              PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
                      SchemeRegistryFactory.createSystemDefault());
              String s = System.getProperty("http.maxConnections", "5");
              int max = Integer.parseInt(s);
              connmgr.setDefaultMaxPerRoute(max);
              connmgr.setMaxTotal(2 * max);
              return connmgr;
          }
        } ;
    } ;
View Full Code Here


    public static void main(String[] args) throws Exception {
        // Create an HttpClient with the ThreadSafeClientConnManager.
        // This connection manager must be used if more than one thread will
        // be using the HttpClient.
        PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
        cm.setMaxTotal(100);

        HttpClient httpclient = new DefaultHttpClient(cm);
        try {
            // create an array of URIs to perform GETs on
            String[] urisToGet = {
View Full Code Here

    {
        if ( networkConfiguration == null )
        {
            // back to default values
            HttpWagon.setUseClientManagerPooled( true );
            poolingClientConnectionManager = new PoolingClientConnectionManager();
            poolingClientConnectionManager.setDefaultMaxPerRoute( 30 );
            poolingClientConnectionManager.setMaxTotal( 30 );
            HttpWagon.setConnectionManagerPooled( poolingClientConnectionManager );

        }
        else
        {
            HttpWagon.setUseClientManagerPooled( networkConfiguration.isUsePooling() );
            poolingClientConnectionManager = new PoolingClientConnectionManager();
            poolingClientConnectionManager.setDefaultMaxPerRoute( networkConfiguration.getMaxTotalPerHost() );
            poolingClientConnectionManager.setMaxTotal( networkConfiguration.getMaxTotal() );
            HttpWagon.setConnectionManagerPooled( poolingClientConnectionManager );
        }
    }
View Full Code Here

  {
    synchronized (httpClientLock)
    {
      if (httpClient == null)
      {
        connectionManager = new PoolingClientConnectionManager();
        BasicHttpParams params = new BasicHttpParams();
        params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
        params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
        //params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,socketTimeOut);
        DefaultHttpClient localHttpClient = new DefaultHttpClient(connectionManager,params);
View Full Code Here

        serverPort = 2099;
      else
        serverPort = new Integer(serverPortString).intValue();

      // Set up connection manager
      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
      localConnectionManager.setMaxTotal(1);
      // Set up ssl if indicated
      keystoreData = params.getParameter(LiveLinkParameters.livelinkKeystore);
      if (keystoreData != null)
      {
        keystoreManager = KeystoreManagerFactory.make("",keystoreData);
        SSLSocketFactory myFactory = new SSLSocketFactory(keystoreManager.getSecureSocketFactory(),
          new BrowserCompatHostnameVerifier());
        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
        localConnectionManager.getSchemeRegistry().register(myHttpsProtocol);
      }
      connectionManager = localConnectionManager;

      // Create the httpclient
      BasicHttpParams params = new BasicHttpParams();
View Full Code Here

  @Override
  public void connect(ConfigParams configParams)
  {
    super.connect(configParams);
    PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
    localConnectionManager.setMaxTotal(1);
    connectionManager = localConnectionManager;
    DefaultHttpClient localClient = new DefaultHttpClient(connectionManager);
    // No retries
    localClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
      {
View Full Code Here

    // Set up the pool.
    // We have a choice: We can either have one httpclient instance, which gets reinitialized for every service
    // it connects with (because each one has a potentially different proxy setup), OR we can have a different
    // httpclient for each service.  The latter approach is obviously the more efficient, so I've chosen to do it
    // that way.
    PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
    localConnectionManager.setMaxTotal(1);
    if (mySSLFactory != null)
    {
      SSLSocketFactory myFactory = new SSLSocketFactory(mySSLFactory, new BrowserCompatHostnameVerifier());
      Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
      localConnectionManager.getSchemeRegistry().register(myHttpsProtocol);
    }
    connectionManager = localConnectionManager;

    // Parse the user and password values
    int index = userName.indexOf("\\");
View Full Code Here

    callUrlSnippet = null;
    serverLocation = config.getServerLocation();
    indexName = config.getIndexName();
    userName = config.getUserName();
    apiKey = config.getApiKey();
    PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
    localConnectionManager.setMaxTotal(1);
    connectionManager = localConnectionManager;
    DefaultHttpClient localHttpClient = new DefaultHttpClient(connectionManager);
    // No retries
    localHttpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
      {
View Full Code Here

      }

      // Set up ssl if indicated
      keystoreData = params.getParameter( "keystore" );

      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
      localConnectionManager.setMaxTotal(1);
      connectionManager = localConnectionManager;

      if (keystoreData != null)
      {
        keystoreManager = KeystoreManagerFactory.make("",keystoreData);
View Full Code Here

        this.username = username;
        this.password = password;
        this.charset = charset;
        this.verbose = verbose;

        PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
        poolingClientConnectionManager.setMaxTotal( 5 );
        this.httpClient = new DefaultHttpClient( poolingClientConnectionManager );
        if ( StringUtils.isNotEmpty( username ) )
        {
            Credentials creds = new UsernamePasswordCredentials( username, password );
View Full Code Here

TOP

Related Classes of org.apache.http.impl.conn.PoolingClientConnectionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.