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

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

Introduction

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

Prototype

public abstract void setBooleanParameter(String paramString, boolean paramBoolean);

Source Link

Usage

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 {// ww w  .j a v a2  s. co m
            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.lockss.plugin.silverchair.PostHttpClientUrlConnection.java

/** Called by org.lockss.config.MiscConfig
 *//*from   w  ww.  j  a  v a2  s.c o m*/
public static void setConfig(Configuration config, Configuration oldConfig, Configuration.Differences diffs) {
    if (diffs.contains(PREFIX)) {
        acceptHeader = config.get(PARAM_ACCEPT_HEADER, DEFAULT_ACCEPT_HEADER);

        Set<String> set = new HashSet();
        for (String s : (List<String>) config.getList(PARAM_SINGLE_VALUED_HEADERS,
                DEFAULT_SINGLE_VALUED_HEADERS)) {
            set.add(s.toLowerCase());
        }
        singleValuedHdrs = set;

        HttpParams params = DefaultHttpParams.getDefaultParams();

        if (diffs.contains(PARAM_COOKIE_POLICY)) {
            String policy = config.get(PARAM_COOKIE_POLICY, DEFAULT_COOKIE_POLICY);
            params.setParameter(HttpMethodParams.COOKIE_POLICY, getCookiePolicy(policy));
        }
        if (diffs.contains(PARAM_SINGLE_COOKIE_HEADER)) {
            boolean val = config.getBoolean(PARAM_SINGLE_COOKIE_HEADER, DEFAULT_SINGLE_COOKIE_HEADER);
            params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, val);
        }
        ServerTrustLevel stl = (ServerTrustLevel) config.getEnum(ServerTrustLevel.class,
                PARAM_SERVER_TRUST_LEVEL, DEFAULT_SERVER_TRUST_LEVEL);
        DISP_FACT.setDefaultFactory(getDefaultSocketFactory(stl));
    }
}

From source file:org.lockss.plugin.silverchair.PostHttpClientUrlConnection.java

public void setKeepAlive(boolean val) {
    assertNotExecuted();//from   w w  w  . jav a2s  .  c om
    HttpParams params = method.getParams();
    params.setBooleanParameter(SO_KEEPALIVE, val);
    // method params don't current work, set in connection pool also,
    // though that won't affect already-open sockets
    connectionPool.setKeepAlive(val);
}

From source file:org.lockss.util.urlconn.HttpClientUrlConnection.java

/** Called by org.lockss.config.MiscConfig
 *//* www  .  ja  v  a 2 s .  com*/
public static void setConfig(Configuration config, Configuration oldConfig, Configuration.Differences diffs) {
    if (diffs.contains(PREFIX)) {
        acceptHeader = config.get(PARAM_ACCEPT_HEADER, DEFAULT_ACCEPT_HEADER);

        HttpParams params = DefaultHttpParams.getDefaultParams();
        if (diffs.contains(PARAM_COOKIE_POLICY)) {
            String policy = config.get(PARAM_COOKIE_POLICY, DEFAULT_COOKIE_POLICY);
            params.setParameter(HttpMethodParams.COOKIE_POLICY, getCookiePolicy(policy));
        }
        if (diffs.contains(PARAM_SINGLE_COOKIE_HEADER)) {
            boolean val = config.getBoolean(PARAM_SINGLE_COOKIE_HEADER, DEFAULT_SINGLE_COOKIE_HEADER);
            params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, val);
        }
        ServerTrustLevel stl = (ServerTrustLevel) config.getEnum(ServerTrustLevel.class,
                PARAM_SERVER_TRUST_LEVEL, DEFAULT_SERVER_TRUST_LEVEL);
        DISP_FACT.setDefaultFactory(getDefaultSocketFactory(stl));
    }
}