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:org.aon.esolutions.appconfig.client.web.SystemPropertiesListener.java

private void loadPropsFromSystem(ServletContext sc) {
    String propertiesLocationProp = sc.getInitParameter("properties.location.property");
    String privateKeyLocationProp = sc.getInitParameter("privatekey.location.property");
    String applicationName = sc.getInitParameter("application.name");
    String environmentName = sc.getInitParameter("environment.name");

    Properties props = System.getProperties();
    String propertiesFileLocation = props.getProperty(propertiesLocationProp);
    String privateKeyLocation = props.getProperty(privateKeyLocationProp);

    if (StringUtils.isEmpty(propertiesFileLocation)) {
        logger.warn("Not loading properties from system property (" + propertiesLocationProp
                + ") as it was not provided.");
        return;// w w  w  .  j a v  a2s  . c  o m
    }

    AppConfigClientFactory acClient = new AppConfigClientFactory();
    acClient.setPropertiesFileName(propertiesFileLocation);
    acClient.setPrivateKeyFileName(privateKeyLocation);

    Properties loadedProps = acClient.getAppConfigClient().loadProperties(applicationName, environmentName);

    for (Map.Entry<Object, Object> e : loadedProps.entrySet()) {
        if (props.containsKey(e.getKey()) == false)
            props.put(e.getKey(), e.getValue());
    }
}

From source file:com.github.persapiens.jsfboot.javaxfaces.JavaxFacesServletContextInitializerIT.java

public void testOnStartup() throws ServletException {
    JavaxFacesServletContextInitializer javaxFacesServletContextInitializer = new JavaxFacesServletContextInitializer(
            this.javaxFacesProperties);

    ServletContext servletContext = new MockServletContext();

    javaxFacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME)).isEqualTo("Development");
}

From source file:com.github.persapiens.jsfboot.primefaces.PrimefacesServletContextInitializerIT.java

public void testOnStartup() throws ServletException {
    PrimefacesServletContextInitializer primefacesServletContextInitializer = new PrimefacesServletContextInitializer(
            this.primefacesProperties);

    ServletContext servletContext = new MockServletContext();

    primefacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(Captcha.PRIVATE_KEY)).isEqualTo("myPrivateCaptchaKey");
}

From source file:org.joinfaces.richfaces.RichfacesServletContextInitializerIT.java

@Test
public void testOnStartup() throws ServletException {
    RichfacesServletContextInitializer bootsfacesServletContextInitializer = new RichfacesServletContextInitializer(
            this.bootsfacesProperties);

    ServletContext servletContext = new MockServletContext();

    bootsfacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter("org.richfaces.skin")).isEqualTo("This is a skin");
}

From source file:org.lightadmin.core.config.StandardLightAdminConfiguration.java

private String helpUrl(ServletContext servletContext) {
    final String helpUrl = servletContext.getInitParameter(LIGHT_ADMINISTRATION_HELP_URL);

    return isBlank(helpUrl) ? LIGHT_ADMINISTRATION_HELP_DEFAULT_URL : helpUrl;
}

From source file:com.github.persapiens.jsfboot.bootsfaces.BootsfacesServletContextInitializerIT.java

public void testOnStartup() throws ServletException {
    BootsfacesServletContextInitializer bootsfacesServletContextInitializer = new BootsfacesServletContextInitializer(
            this.bootsfacesProperties);

    ServletContext servletContext = new MockServletContext();

    bootsfacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(C.P_THEME)).isEqualTo("bootstrap");
}

From source file:com.indeed.boxcar.server.servlet.AbstractBoxcarContextListener.java

protected int getRequiredIntInitParameter(final ServletContext servletContext, final String initParameterName) {
    final String initParameterValue = servletContext.getInitParameter(initParameterName);
    if (initParameterValue == null) {
        throw new RuntimeException("'" + initParameterName + "' parameter not set in servlet context");
    }/*from  w  w w  .j  ava 2  s  .com*/
    return Integer.parseInt(initParameterValue);
}

From source file:org.joinfaces.bootsfaces.BootsfacesServletContextInitializerIT.java

@Test
public void testOnStartup() throws ServletException {
    BootsfacesServletContextInitializer bootsfacesServletContextInitializer = new BootsfacesServletContextInitializer(
            this.bootsfacesProperties);

    ServletContext servletContext = new MockServletContext();

    bootsfacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(C.P_THEME)).isEqualTo("bootstrap");
}

From source file:org.joinfaces.javaxfaces.JavaxFacesServletContextInitializerIT.java

@Test
public void testOnStartup() throws ServletException {
    JavaxFacesServletContextInitializer javaxFacesServletContextInitializer = new JavaxFacesServletContextInitializer(
            this.javaxFacesProperties);

    ServletContext servletContext = new MockServletContext();

    javaxFacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME)).isEqualTo("Development");
}

From source file:org.joinfaces.primefaces.PrimefacesServletContextInitializerIT.java

@Test
public void testOnStartup() throws ServletException {
    PrimefacesServletContextInitializer primefacesServletContextInitializer = new PrimefacesServletContextInitializer(
            this.primefacesProperties);

    ServletContext servletContext = new MockServletContext();

    primefacesServletContextInitializer.onStartup(servletContext);

    assertThat(servletContext.getInitParameter(Captcha.PRIVATE_KEY)).isEqualTo("myPrivateCaptchaKey");
}