Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpConnectionManager


    public synchronized void run() {
        while (!shutdown) {
            Iterator iter = connectionManagers.iterator();
           
            while (iter.hasNext()) {
                HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next();
                connectionManager.closeIdleConnections(connectionTimeout);
            }
           
            try {
                this.wait(timeoutInterval);
            } catch (InterruptedException e) {
View Full Code Here


     * held open. This is an optional method, and callers are not expected to
     * call it, but can if they want to explicitly release any open resources.
     * Once a client has been shutdown, it cannot be used to make more requests.
     */
    public void shutdown() {
        HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager)connectionManager).shutdown();
        }
    }
View Full Code Here

        }
    }

    @Override
    public void destroy() throws Exception {
        HttpConnectionManager connectionManager = getHttpClient().getHttpConnectionManager();
        if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
            ((MultiThreadedHttpConnectionManager) connectionManager).shutdown();
        }
    }
View Full Code Here

    @Override
    public void closeCommunicationLink()
    {
        if (getClient() != null)
        {
            HttpConnectionManager mgr = getClient().getHttpConnectionManager();
            if (mgr instanceof MultiThreadedHttpConnectionManager)
            {
                ((MultiThreadedHttpConnectionManager) mgr).shutdown();
            }
        }
View Full Code Here

            throws FileSystemException
    {
        HttpClient client;
        try
        {
            HttpConnectionManager mgr = new MultiThreadedHttpConnectionManager();
            HttpConnectionManagerParams connectionMgrParams = mgr.getParams();

            client = new HttpClient(mgr);

            final HostConfiguration config = new HostConfiguration();
            config.setHost(hostname, port, scheme);
View Full Code Here

    public boolean interrupt() {
        HttpClient client = savedClient;
        if (client != null) {
            savedClient = null;
            // TODO - not sure this is the best method
            final HttpConnectionManager httpConnectionManager = client.getHttpConnectionManager();
            if (httpConnectionManager instanceof SimpleHttpConnectionManager) {// Should be true
                ((SimpleHttpConnectionManager)httpConnectionManager).shutdown();
            }
        }
        return client != null;
View Full Code Here

              Configurator configurator = createConfigurator(configuratorClass);
              configurator.configure(httpClient, properties);
          }
        }

        final HttpConnectionManager connectionManager = httpClient.getHttpConnectionManager();
        if (connectionManager instanceof ESBMultiThreadedHttpConnectionManager) {
            final ESBMultiThreadedHttpConnectionManager esbMultiThreadedHttpConnectionManager = (ESBMultiThreadedHttpConnectionManager)connectionManager;
            esbMultiThreadedHttpConnectionManager.setHostConfiguration(httpClient.getHostConfiguration()) ;
        }
       
View Full Code Here

     * Shutdown http client and associated connections.
     * @param httpclient The http client
     */
    public static void shutdown(final HttpClient httpclient) {
        if (httpclient != null) {
            final HttpConnectionManager connectionManager = httpclient.getHttpConnectionManager();
            if (connectionManager instanceof MultiThreadedHttpConnectionManager) {
                final MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = (MultiThreadedHttpConnectionManager)connectionManager;
                multiThreadedHttpConnectionManager.shutdown();
            }
        }
View Full Code Here

     * Max connections per host.
     */
    public static final String MAX_CONNECTIONS_PER_HOST = "max-connections-per-host";

    public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException {
        final HttpConnectionManager connectionManager = new ESBMultiThreadedHttpConnectionManager() ;
        final String maxTotalConnections = properties.getProperty(MAX_TOTAL_CONNECTIONS) ;
        final String maxConnectionsPerHost = properties.getProperty(MAX_CONNECTIONS_PER_HOST) ;

        connectionManager.setParams(new ESBHttpConnectionManagerParams(maxTotalConnections, maxConnectionsPerHost)) ;
        httpClient.setHttpConnectionManager(connectionManager);
    }
View Full Code Here

            final HttpClient secondHttpClient = HttpClientFactory.createHttpClient(secondProperties) ;
            try
            {
                final HostConfiguration firstConfiguration = firstHttpClient.getHostConfiguration() ;
                final HttpConnectionManagerParams firstParams = firstHttpClient.getHttpConnectionManager().getParams() ;
                final HttpConnectionManager firstConnectionManager = firstHttpClient.getHttpConnectionManager() ;
               
                assertEquals("MAX_TOTAL_CONNECTIONS not set", firstMaxTotalConnections, firstParams.getMaxTotalConnections()) ;
                assertEquals("MAX_CONNECTIONS_PER_HOST not set", firstMaxConnectionsPerHost, firstParams.getMaxConnectionsPerHost(firstConfiguration)) ;
                assertNotNull("connection manager is null", firstConnectionManager) ;
                assertEquals("connection manager is not correct type", ESBMultiThreadedHttpConnectionManager.class, firstConnectionManager.getClass()) ;
                assertNotNull("HostConfiguration is null", ((ESBMultiThreadedHttpConnectionManager)firstConnectionManager).getHostConfiguration()) ;
               
                final HostConfiguration secondConfiguration = secondHttpClient.getHostConfiguration() ;
                final HttpConnectionManagerParams secondParams = secondHttpClient.getHttpConnectionManager().getParams() ;
                final HttpConnectionManager secondConnectionManager = secondHttpClient.getHttpConnectionManager() ;
               
                assertEquals("MAX_TOTAL_CONNECTIONS not set", secondMaxTotalConnections, secondParams.getMaxTotalConnections()) ;
                assertEquals("MAX_CONNECTIONS_PER_HOST not set", secondMaxConnectionsPerHost, secondParams.getMaxConnectionsPerHost(secondConfiguration)) ;
                assertNotNull("connection manager is null", secondConnectionManager) ;
                assertEquals("connection manager is not correct type", ESBMultiThreadedHttpConnectionManager.class, secondConnectionManager.getClass()) ;
                assertNotNull("HostConfiguration is null", ((ESBMultiThreadedHttpConnectionManager)secondConnectionManager).getHostConfiguration()) ;
            }
            finally
            {
                HttpClientFactory.shutdown(secondHttpClient) ;
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HttpConnectionManager

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.