Example usage for org.apache.commons.httpclient.params HttpParams setIntParameter

List of usage examples for org.apache.commons.httpclient.params HttpParams setIntParameter

Introduction

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

Prototype

public abstract void setIntParameter(String paramString, int paramInt);

Source Link

Usage

From source file:com.cloudbees.api.BeesClientBase.java

public InputStream executeCometRequest(String url) throws Exception {
    HttpClient httpClient = HttpClientHelper.createClient(this.beesClientConfiguration);
    HttpParams params = httpClient.getParams();
    params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 0);
    GetMethod getMethod = new GetMethod(url);
    httpClient.executeMethod(getMethod);
    return getMethod.getResponseBodyAsStream();
}

From source file:org.kuali.rice.kew.config.ThinClientResourceLoader.java

protected void configureDefaultHttpClientParams(HttpParams params) {
    params.setParameter(HttpClientParams.CONNECTION_MANAGER_CLASS, MultiThreadedHttpConnectionManager.class);
    params.setParameter(HttpMethodParams.COOKIE_POLICY, CookiePolicy.RFC_2109);
    params.setLongParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT,
            new Long(DEFAULT_CONNECTION_MANAGER_TIMEOUT));
    Map<HostConfiguration, Integer> maxHostConnectionsMap = new HashMap<HostConfiguration, Integer>();
    maxHostConnectionsMap.put(HostConfiguration.ANY_HOST_CONFIGURATION, new Integer(DEFAULT_MAX_CONNECTIONS));
    params.setParameter(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, maxHostConnectionsMap);
    params.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
            new Integer(DEFAULT_MAX_CONNECTIONS));
    params.setIntParameter(HttpConnectionManagerParams.CONNECTION_TIMEOUT,
            new Integer(DEFAULT_CONNECTION_TIMEOUT));

    boolean retrySocketException = new Boolean(
            ConfigContext.getCurrentContextConfig().getProperty(RETRY_SOCKET_EXCEPTION_PROPERTY));
    if (retrySocketException) {
        LOG.info("Installing custom HTTP retry handler to retry requests in face of SocketExceptions");
        params.setParameter(HttpMethodParams.RETRY_HANDLER, new CustomHttpMethodRetryHandler());
    }/*from   w ww . j  a v  a2s. c  om*/
}

From source file:org.kuali.rice.ksb.messaging.HttpClientHelper.java

public static void setParameter(HttpParams params, String paramName, String paramValue) {
    Class<?> paramType = getParameterType(paramName);
    if (paramType.equals(Boolean.class)) {
        params.setBooleanParameter(paramName, Boolean.parseBoolean(paramValue));
    } else if (paramType.equals(Integer.class)) {
        params.setIntParameter(paramName, Integer.parseInt(paramValue));
    } else if (paramType.equals(Long.class)) {
        params.setLongParameter(paramName, Long.parseLong(paramValue));
    } else if (paramType.equals(Double.class)) {
        params.setDoubleParameter(paramName, Double.parseDouble(paramValue));
    } else if (paramType.equals(String.class)) {
        params.setParameter(paramName, paramValue);
    } else if (paramType.equals(Class.class)) {
        try {//w  ww. ja v  a2 s . c om
            Class<?> configuredClass = Class.forName(paramValue, true,
                    ClassLoaderUtils.getDefaultClassLoader());
            params.setParameter(paramName, configuredClass);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Could not locate the class needed to configure the HttpClient.", e);
        }
    } else {
        throw new RuntimeException("Attempted to configure an HttpClient parameter '" + paramName + "' "
                + "of a type not supported through Workflow configuration: " + paramType.getName());
    }
}

From source file:org.kuali.rice.ksb.messaging.serviceconnectors.HttpInvokerConnector.java

protected void configureDefaultHttpClientParams(HttpParams params) {
    params.setParameter(HttpClientParams.CONNECTION_MANAGER_CLASS, MultiThreadedHttpConnectionManager.class);
    params.setParameter(HttpMethodParams.COOKIE_POLICY, CookiePolicy.RFC_2109);
    params.setLongParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 10000);
    Map<HostConfiguration, Integer> maxHostConnectionsMap = new HashMap<HostConfiguration, Integer>();
    maxHostConnectionsMap.put(HostConfiguration.ANY_HOST_CONFIGURATION, new Integer(20));
    params.setParameter(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, maxHostConnectionsMap);
    params.setIntParameter(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 20);
    params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 10000);
    params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 2 * 60 * 1000);

    boolean retrySocketException = new Boolean(
            ConfigContext.getCurrentContextConfig().getProperty(RETRY_SOCKET_EXCEPTION_PROPERTY));
    if (retrySocketException) {
        LOG.info("Installing custom HTTP retry handler to retry requests in face of SocketExceptions");
        params.setParameter(HttpMethodParams.RETRY_HANDLER, new CustomHttpMethodRetryHandler());
    }/*  ww w . j  a  v  a2s .c  om*/

}