Example usage for javax.servlet FilterConfig getInitParameter

List of usage examples for javax.servlet FilterConfig getInitParameter

Introduction

In this page you can find the example usage for javax.servlet FilterConfig getInitParameter.

Prototype

public String getInitParameter(String name);

Source Link

Document

Returns a String containing the value of the named initialization parameter, or null if the initialization parameter does not exist.

Usage

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns the init parameters for a {@link javax.servlet.FilterConfig} object as a Map, preserving the order in which they are exposed
 * by the {@link javax.servlet.FilterConfig} object.
 *///w ww.  ja v  a  2  s.  c o m
public static LinkedHashMap<String, String> initParametersToMap(FilterConfig config) {
    LinkedHashMap<String, String> initParameters = new LinkedHashMap<String, String>();
    Enumeration parameterNames = config.getInitParameterNames();
    while (parameterNames.hasMoreElements()) {
        String parameterName = (String) parameterNames.nextElement();
        initParameters.put(parameterName, config.getInitParameter(parameterName));
    }
    return initParameters;
}

From source file:org.apache.hadoop.gateway.dispatch.DefaultHttpClientFactory.java

private static int getSocketTimeout(FilterConfig filterConfig) {
    int timeout = -1;
    GatewayConfig globalConfig = (GatewayConfig) filterConfig.getServletContext()
            .getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
    if (globalConfig != null) {
        timeout = globalConfig.getHttpClientSocketTimeout();
    }/*from ww w  . j a v  a2 s  .  c  o m*/
    String str = filterConfig.getInitParameter("httpclient.socketTimeout");
    if (str != null) {
        try {
            timeout = (int) parseTimeout(str);
        } catch (Exception e) {
            // Ignore it and use the default.
        }
    }
    return timeout;
}

From source file:org.apache.hadoop.gateway.dispatch.DefaultHttpClientFactory.java

private static int getConnectionTimeout(FilterConfig filterConfig) {
    int timeout = -1;
    GatewayConfig globalConfig = (GatewayConfig) filterConfig.getServletContext()
            .getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
    if (globalConfig != null) {
        timeout = globalConfig.getHttpClientConnectionTimeout();
    }//  w w w.j ava2 s.  c om
    String str = filterConfig.getInitParameter("httpclient.connectionTimeout");
    if (str != null) {
        try {
            timeout = (int) parseTimeout(str);
        } catch (Exception e) {
            // Ignore it and use the default.
        }
    }
    return timeout;
}

From source file:org.wso2.carbon.identity.sso.agent.util.SSOAgentConfigs.java

public static void initConfig(FilterConfig fConfigs) throws SSOAgentException {

    Properties properties = new Properties();
    try {//from  ww w . j  a v  a  2 s. co m
        if (fConfigs.getInitParameter("SSOAgentPropertiesFilePath") != null
                && !"".equals(fConfigs.getInitParameter("SSOAgentPropertiesFilePath"))) {
            properties.load(new FileInputStream(fConfigs.getInitParameter("SSOAgentPropertiesFilePath")));
            initConfig(properties);
        } else {
            LOGGER.warning("\'SSOAgentPropertiesFilePath\' not configured");
        }
    } catch (FileNotFoundException e) {
        if (log.isDebugEnabled()) {
            log.debug("File not found  ", e);
        }
        throw new SSOAgentException("Agent properties file not found");

    } catch (IOException e) {

        throw new SSOAgentException("Error occurred while reading Agent properties file", e);
    }

}

From source file:gov.loc.ndmso.proxyfilter.Log.java

/**
 * Will setup Log based on the filter config.  Uses init paramater "logLevel" to get the log level.
 * Defaults to "INFO"./*from w  w  w .ja v  a2s  .c om*/
 *
 * @param filterConfig the filter config to use
 */
public static void setConfiguration(final FilterConfig filterConfig) {
    resetAll();

    if (filterConfig == null) {
        localLog.error("no filter config passed");
        return;
    }
    Log.context = filterConfig.getServletContext();

    String logLevelConf = filterConfig.getInitParameter("logLevel");

    if (logLevelConf != null) {
        logLevelConf = trimStr(logLevelConf);
    }

    setLevel(logLevelConf);
    localLog.debug("logLevel set to " + logLevelConf);
}

From source file:org.tuckey.web.filters.urlrewrite.utils.Log.java

/**
 * Will setup Log based on the filter config.  Uses init paramater "logLevel" to get the log level.
 * Defaults to "INFO".//w w  w  .  j a  v  a  2  s  . co  m
 *
 * @param filterConfig the filter config to use
 */
public static void setConfiguration(final FilterConfig filterConfig) {
    resetAll();

    if (filterConfig == null) {
        localLog.error("no filter config passed");
        return;
    }
    Log.context = filterConfig.getServletContext();

    String logLevelConf = filterConfig.getInitParameter("logLevel");

    if (logLevelConf != null) {
        logLevelConf = StringUtils.trim(logLevelConf);
    }

    setLevel(logLevelConf);
    localLog.debug("logLevel set to " + logLevelConf);
}

From source file:jrouter.servlet.filter.SpringBeanJRouterFilter.java

@Override
public void init(FilterConfig filterConfig) {
    beanName = filterConfig.getInitParameter("beanName");
    if (beanName != null)
        log.info("Set bean's name of springframework : " + beanName);
    super.init(filterConfig);
}

From source file:cn.vlabs.umt.ui.servlet.filters.P3PConfigFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    p3p = config.getInitParameter("p3pConfig");
}

From source file:de.highbyte_le.weberknecht.security.filters.LoginPageForwardFilter.java

@Override
public void init(FilterConfig config) {
    loginPage = config.getInitParameter("login_page");
}

From source file:org.opensubsystems.core.util.servlet.WebUtils.java

/**
 * Get names and values for all the init parameters from the specified 
 * filter config.//from w w  w .  j a va 2  s  . c o m
 * 
 * @param  fcConfig - config from where to retrieve the init parameters
 * @return Properties - names and values of the init parameters or empty
 *                      properties if no init parameters are specified
 */
public static Properties getInitParameters(FilterConfig fcConfig) {
    Properties prpSettings = new Properties();
    String strName;
    String strValue;

    for (Enumeration paramNames = fcConfig.getInitParameterNames(); paramNames.hasMoreElements();) {
        strName = (String) paramNames.nextElement();
        strValue = fcConfig.getInitParameter(strName);
        prpSettings.put(strName, strValue);
    }

    return prpSettings;
}