Example usage for javax.servlet ServletContext getInitParameter

List of usage examples for javax.servlet ServletContext getInitParameter

Introduction

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

Prototype

public String getInitParameter(String name);

Source Link

Document

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

Usage

From source file:com.googlecode.psiprobe.tools.SecurityUtils.java

private static String getPrivilegedRoles(ServletContext servletContext) {
    return servletContext.getInitParameter("attribute.value.roles");
}

From source file:psiprobe.tools.SecurityUtils.java

/**
 * Gets the privileged roles.//w  w w  . j av  a2  s  . c  o m
 *
 * @param servletContext the servlet context
 * @return the privileged roles
 */
private static String getPrivilegedRoles(ServletContext servletContext) {
    return servletContext.getInitParameter("attribute.value.roles");
}

From source file:org.apache.hawq.pxf.service.utilities.Log4jConfigure.java

/**
 * Initializes log4j logging for the webapp.
 *
 * Reads log4j properties file location from log4jConfigLocation parameter
 * in web.xml. When not using aboslute path, the path starts from the webapp
 * root directory. If the file can't be read, reverts to default
 * configuration file under WEB-INF/classes/pxf-log4j.properties.
 *
 * @param event Servlet context, used to determine webapp root directory.
 */// w w  w.  j  av  a2  s.  c om
public static void configure(ServletContextEvent event) {

    final String defaultLog4jLocation = "WEB-INF/classes/pxf-log4j.properties";

    ServletContext context = event.getServletContext();
    String log4jConfigLocation = context.getInitParameter("log4jConfigLocation");

    if (!log4jConfigLocation.startsWith(File.separator)) {
        log4jConfigLocation = context.getRealPath("") + File.separator + log4jConfigLocation;
    }

    // revert to default properties file if file doesn't exist
    File log4jConfigFile = new File(log4jConfigLocation);
    if (!log4jConfigFile.canRead()) {
        log4jConfigLocation = context.getRealPath("") + File.separator + defaultLog4jLocation;
    }
    PropertyConfigurator.configure(log4jConfigLocation);
    LOG.info("log4jConfigLocation = " + log4jConfigLocation);
}

From source file:com.headissue.pigeon.PigeonBootstrapListener.java

static String getParam(ServletContext _context, String _name) {
    String s = _context.getInitParameter(_name);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in servlet:   '%s'=%s", _name, s);
        return s;
    }/*w  ww  .ja va 2s .  c o m*/
    String _envName = _name.replaceAll("\\.", "_");
    s = System.getenv(_envName);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in env param: '%s'=%s", _envName, s);
        return s;
    }
    s = System.getProperty(_name);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in sys prop:  '%s'=%s", _name, s);
    }
    return s;
}

From source file:com.shengpay.commons.bp.logback.LogbackWebConfigurer.java

/**
 * Return whether to expose the web app root system property, checking the corresponding ServletContext init parameter.
 * /* w  w  w. jav a 2s . c  om*/
 * @see #EXPOSE_WEB_APP_ROOT_PARAM
 */
private static boolean exposeWebAppRoot(ServletContext servletContext) {
    String exposeWebAppRootParam = servletContext.getInitParameter(EXPOSE_WEB_APP_ROOT_PARAM);
    return (exposeWebAppRootParam == null || Boolean.valueOf(exposeWebAppRootParam));
}

From source file:com.excilys.ebi.utils.spring.log.logback.web.LogbackWebConfigurer.java

/**
 * Search for a specified config location, first in the servlet context and
 * then as a System property/*from ww w. j av a2  s.  c  om*/
 * 
 * @param servletContext
 *            the servletContext
 * @return the config location
 */
private static String getConfigLocation(ServletContext servletContext) {
    String location = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
    if (location == null) {
        location = System.getProperty(CONFIG_LOCATION_PARAM);
    }
    return location;
}

From source file:org.nuxeo.ecm.web.embedded.NuxeoEmbeddedLoader.java

protected static FrameworkBootstrap loadRuntime(ServletContext context) {
    String warFile = context.getRealPath("");
    String root = context.getInitParameter("nxhome");
    if (root == null) {
        root = "";
    }//from   w ww. j av  a2s  . c  o m
    File appRoot = null;
    if (root.startsWith("/")) {
        appRoot = new File(root);
    } else {
        appRoot = new File(warFile + "/" + root);
    }
    root = appRoot.getAbsolutePath();

    FrameworkBootstrap fb;
    try {
        fb = new FrameworkBootstrap(NuxeoFilter.class.getClassLoader(), appRoot);
        fb.initialize();
        fb.start();
    } catch (Exception e) {
        throw new Error("Cannot load embedded server", e);
    }
    return fb;
}

From source file:org.pentaho.platform.web.http.PentahoHttpSessionHelper.java

public static String getSolutionPath(final ServletContext context) {
    File pentahoSolutions;/*from   ww  w.  j a  v a  2s.c o m*/

    // first try the web.xml setting
    String rootPath = context.getInitParameter("solution-path"); //$NON-NLS-1$
    if (StringUtils.isNotBlank(rootPath)) {
        pentahoSolutions = new File(rootPath);
        if (pentahoSolutions.exists() && pentahoSolutions.isDirectory()) {
            return rootPath;
        }
    }

    for (String element : DEFAULT_LOCATIONS) {
        pentahoSolutions = new File(element);
        if (pentahoSolutions.exists() && pentahoSolutions.isDirectory()) {
            try {
                return pentahoSolutions.getCanonicalPath();
            } catch (IOException e) {
                return pentahoSolutions.getAbsolutePath();
            }
        }
    }

    // now try the path to the WEB-INF to see if we find
    File file = new File(context.getRealPath("")); //$NON-NLS-1$
    while (file != null) {
        if (file.exists() && file.isDirectory()) {
            pentahoSolutions = new File(file.getAbsolutePath() + File.separator + "pentaho-solutions"); //$NON-NLS-1$
            if (pentahoSolutions.exists() && pentahoSolutions.isDirectory()) {
                try {
                    return pentahoSolutions.getCanonicalPath();
                } catch (IOException e) {
                    return pentahoSolutions.getAbsolutePath();
                }
            }
        }
        file = file.getParentFile();
    }
    return null;
}

From source file:org.glite.slcs.attribute.AttributeDefinitionsFactory.java

/**
 * Initializes the factory using the servlet context parameter
 * <code>AttributeDefintionsFile</code>.
 * //  w  w  w.ja  va  2  s. c  om
 * @param context
 *            The servlet context.
 * @throws SLCSException
 *             If the servlet context parameter is missing or if an error
 *             occurs.
 */
static public synchronized void initialize(ServletContext context) throws SLCSException {
    LOG.debug("initialize AttributeDefintionsFactory(ServletContext)");
    String filename = context.getInitParameter(ATTRIBUTE_DEFINITIONS_FILE_KEY);
    if (filename == null) {
        LOG.error("Parameter " + ATTRIBUTE_DEFINITIONS_FILE_KEY + " not found in the servlet context");
        throw new SLCSConfigurationException(
                "Parameter " + ATTRIBUTE_DEFINITIONS_FILE_KEY + " not found in the servlet context");
    }
    initialize(filename);
}

From source file:eu.openanalytics.rsb.config.BootstrapConfigurationServletContextListener.java

private static String getConfiguredConfigurationFileName(final ServletContext servletContext) {
    return servletContext.getInitParameter(RSB_CONFIGURATION_SERVLET_CONTEXT_PARAM);
}