Example usage for org.apache.commons.httpclient.params HttpConnectionManagerParams HttpConnectionManagerParams

List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams HttpConnectionManagerParams

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.params HttpConnectionManagerParams HttpConnectionManagerParams.

Prototype

HttpConnectionManagerParams

Source Link

Usage

From source file:org.intalio.tempo.workflow.tas.sling.SlingStorageStrategy.java

public void init() throws HttpException, IOException {
    HostConfiguration hostConfig = new HostConfiguration();
    // hostConfig.setHost("www.somehost.com");
    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    int maxHostConnections = 20;
    params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
    connectionManager.setParams(params);
    httpclient = new HttpClient(connectionManager);
    Credentials creds = new UsernamePasswordCredentials(userName, password);
    httpclient.getState().setCredentials(AuthScope.ANY, creds);
    httpclient.setHostConfiguration(hostConfig);

    MkColMethod col = new MkColMethod(getUploadFolder());
    int ret = httpclient.executeMethod(col);
    log.debug(MessageFormatter.format("Created folder {0} in sling: {1}", getUploadFolder(), ret));
}

From source file:org.jahia.services.notification.HttpClientServiceTest.java

private void initClient() {
    // instantiate HttpClient
    HttpClientParams params = new HttpClientParams();
    params.setAuthenticationPreemptive(true);
    params.setCookiePolicy("ignoreCookies");

    HttpConnectionManagerParams cmParams = new HttpConnectionManagerParams();
    cmParams.setConnectionTimeout(15000);
    cmParams.setSoTimeout(60000);/*w  w  w.  j a  va2s .  c om*/

    MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
    httpConnectionManager.setParams(cmParams);

    httpClientService = new HttpClientService();
    httpClientService.setHttpClient(new HttpClient(params, httpConnectionManager));
}

From source file:org.jboss.test.cluster.defaultcfg.web.test.CleanShutdownTestCase.java

/**
 * @see org.jboss.test.JBossClusteredTestCase#setUp()
 *//*  www  .j a  v a  2 s  .  c om*/
@Override
protected void setUp() throws Exception {
    super.setUp();

    this.name = ObjectName.getInstance(SERVER_NAME);
    this.server = this.getAdaptors()[0];
    this.baseURL = this.getHttpURLs()[0];

    this.manager = new MultiThreadedHttpConnectionManager();

    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(MAX_THREADS);
    params.setMaxTotalConnections(MAX_THREADS);

    this.manager.setParams(params);

    this.client = new HttpClient();
}

From source file:org.mule.transport.http.HttpConnector.java

@Override
protected void doInitialise() throws InitialisationException {
    super.doInitialise();
    if (clientConnectionManager == null) {
        clientConnectionManager = new MultiThreadedHttpConnectionManager();
        String prop = System.getProperty("mule.http.disableCleanupThread");
        disableCleanupThread = prop != null && prop.equals("true");
        if (!disableCleanupThread) {
            connectionCleaner = new IdleConnectionTimeoutThread();
            connectionCleaner.setName("HttpClient-connection-cleaner-" + getName());
            connectionCleaner.addConnectionManager(clientConnectionManager);
            connectionCleaner.start();//  w ww.  j  a va2 s  . c om
        }

        HttpConnectionManagerParams params = new HttpConnectionManagerParams();
        if (getSendBufferSize() != INT_VALUE_NOT_SET) {
            params.setSendBufferSize(getSendBufferSize());
        }
        if (getReceiveBufferSize() != INT_VALUE_NOT_SET) {
            params.setReceiveBufferSize(getReceiveBufferSize());
        }
        if (getClientSoTimeout() != INT_VALUE_NOT_SET) {
            params.setSoTimeout(getClientSoTimeout());
        }
        if (getSocketSoLinger() != INT_VALUE_NOT_SET) {
            params.setLinger(getSocketSoLinger());
        }

        params.setTcpNoDelay(isSendTcpNoDelay());
        params.setMaxTotalConnections(dispatchers.getMaxTotal());
        params.setDefaultMaxConnectionsPerHost(dispatchers.getMaxTotal());
        clientConnectionManager.setParams(params);
    }
    //connection manager must be created during initialization due that devkit requires the connection manager before start phase.
    //That's why it not manager only during stop/start phases and must be created also here.
    if (connectionManager == null) {
        try {
            connectionManager = new org.mule.transport.http.HttpConnectionManager(this,
                    getReceiverWorkManager());
        } catch (MuleException e) {
            throw new InitialisationException(
                    CoreMessages.createStaticMessage("failed creating http connection manager"), this);
        }
    }
}

From source file:org.nuxeo.ecm.webdav.JackRabbitParallelBench.java

private HttpClient createClient() {
    HostConfiguration hostConfig = new HostConfiguration();
    hostConfig.setHost("localhost", PORT);

    //HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManager connectionManager = new SimpleHttpConnectionManager(true);
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setMaxConnectionsPerHost(hostConfig, 10);
    connectionManager.setParams(params);

    HttpClient client = new HttpClient(connectionManager);
    client.setHostConfiguration(hostConfig);

    Credentials creds = new UsernamePasswordCredentials(LOGIN, PASSWD);
    client.getState().setCredentials(AuthScope.ANY, creds);

    return client;
}

From source file:org.nuxeo.ecm.webdav.JackrabbitWebdavClientTest.java

@BeforeClass
public static void setUp() {
    // Setup code
    HostConfiguration hostConfig = new HostConfiguration();
    hostConfig.setHost("localhost", PORT);

    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    int maxHostConnections = 20;
    params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
    connectionManager.setParams(params);

    client = new HttpClient(connectionManager);
    client.setHostConfiguration(hostConfig);

    Credentials creds = new UsernamePasswordCredentials("userId", "pw");
    client.getState().setCredentials(AuthScope.ANY, creds);
}

From source file:org.nuxeo.ecm.webdav.ParallelBench.java

private HttpClient createClient() {
    HostConfiguration hostConfig = new HostConfiguration();
    hostConfig.setHost("localhost", PORT);

    // HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManager connectionManager = new SimpleHttpConnectionManager(true);
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setMaxConnectionsPerHost(hostConfig, 10);
    connectionManager.setParams(params);

    HttpClient client = new HttpClient(connectionManager);
    client.setHostConfiguration(hostConfig);

    Credentials creds = new UsernamePasswordCredentials(LOGIN, PASSWD);
    client.getState().setCredentials(AuthScope.ANY, creds);

    return client;
}

From source file:org.nuxeo.ecm.webdav.WebDavClientTest.java

protected static HttpClient createClient(String username, String password) {
    HostConfiguration hostConfig = new HostConfiguration();
    hostConfig.setHost("localhost", WebDavServerFeature.PORT);

    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    int maxHostConnections = 20;
    params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
    connectionManager.setParams(params);

    HttpClient httpClient = new HttpClient(connectionManager);
    httpClient.setHostConfiguration(hostConfig);

    Credentials creds = new UsernamePasswordCredentials(username, password);
    httpClient.getState().setCredentials(AuthScope.ANY, creds);
    httpClient.getParams().setAuthenticationPreemptive(true);
    return httpClient;
}

From source file:org.openrdf.http.client.HTTPClient.java

public HTTPClient() {
    valueFactory = ValueFactoryImpl.getInstance();

    // Use MultiThreadedHttpConnectionManager to allow concurrent access on
    // HttpClient
    manager = new MultiThreadedHttpConnectionManager();

    // Allow 20 concurrent connections to the same host (default is 2)
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(20);
    manager.setParams(params);//from  w  w  w.j  ava 2 s.com

    httpClient = new HttpClient(manager);

    configureProxySettings(httpClient);
}

From source file:org.openrdf.repository.sparql.SPARQLConnection.java

public SPARQLConnection(SPARQLRepository repository, String queryEndpointUrl, String updateEndpointUrl) {
    super(repository);
    this.queryEndpointUrl = queryEndpointUrl;
    this.updateEndpointUrl = updateEndpointUrl;

    // Use MultiThreadedHttpConnectionManager to allow concurrent access on
    // HttpClient
    HttpConnectionManager manager = new MultiThreadedHttpConnectionManager();

    // Allow 20 concurrent connections to the same host (default is 2)
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(20);
    params.setStaleCheckingEnabled(false);
    manager.setParams(params);// www. j av a 2 s .c om

    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setParameter(HttpMethodParams.USER_AGENT,
            APP_NAME + "/" + VERSION + " " + clientParams.getParameter(HttpMethodParams.USER_AGENT));
    // set additional HTTP headers, if desired by the user
    if (repository.getAdditionalHttpHeaders() != null)
        clientParams.setParameter(ADDITIONAL_HEADER_NAME, repository.getAdditionalHttpHeaders());
    client = new HttpClient(clientParams, manager);
}