Package org.apache.commons.httpclient.util

Examples of org.apache.commons.httpclient.util.IdleConnectionTimeoutThread


    log.debug("MAXCONNECTIONS: "+connectionParams.getMaxTotalConnections());
    log.debug("MAXCONNECTIONSPERHOST: "+connectionParams.getDefaultMaxConnectionsPerHost());
   
    // handle idle connections
    connectionManager.closeIdleConnections(IDLE_TIMEOUT_MS);
    idleConnectionHandler = new IdleConnectionTimeoutThread();
    idleConnectionHandler.addConnectionManager(connectionManager);
    idleConnectionHandler.start();
  }
View Full Code Here


     */
    public void testTimeoutThread() {
       
        TimeoutHttpConnectionManager cm = new TimeoutHttpConnectionManager();       
       
        IdleConnectionTimeoutThread timeoutThread = new IdleConnectionTimeoutThread();
        timeoutThread.addConnectionManager(cm);
        timeoutThread.setTimeoutInterval(100);
        timeoutThread.start();
       
        synchronized(this) {
            try {
                this.wait(250);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
       
        assertTrue("closeIdleConnections() not called", cm.closed);

        timeoutThread.removeConnectionManager(cm);
        cm.closed = false;
       
        synchronized(this) {
            try {
                this.wait(250);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        assertFalse("closeIdleConnections() called", cm.closed);
       
        timeoutThread.shutdown();
    }   
View Full Code Here

        // 创建一个线程安全的HTTP连接池
        connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost);
        connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn);

        IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread();
        ict.addConnectionManager(connectionManager);
        ict.setConnectionTimeout(defaultIdleConnTimeout);

        ict.start();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.util.IdleConnectionTimeoutThread

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.