Example usage for org.apache.commons.configuration SystemConfiguration SystemConfiguration

List of usage examples for org.apache.commons.configuration SystemConfiguration SystemConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration SystemConfiguration SystemConfiguration.

Prototype

public SystemConfiguration() 

Source Link

Document

Create a Configuration based on the system properties.

Usage

From source file:org.ejbca.extra.util.ExtraConfiguration.java

public static Configuration instance() {
    if (config == null) {
        try {/*from www. j a v a2 s.  c  om*/
            // Default values build into war file, this is last prio used if no of the other sources override this
            boolean allowexternal = Boolean.getBoolean(
                    new PropertiesConfiguration(ExtraConfiguration.class.getResource("/" + PROPERTY_FILENAME))
                            .getString(CONFIGALLOWEXTERNAL, "false"));

            config = new CompositeConfiguration();

            PropertiesConfiguration pc;
            // Only add these config sources if we allow external configuration
            if (allowexternal) {
                // Override with system properties, this is prio 1 if it exists (java -Dscep.test=foo)
                config.addConfiguration(new SystemConfiguration());
                log.info("Added system properties to configuration source (java -Dfoo.prop=bar).");

                // Override with file in "application server home directory"/conf, this is prio 2
                File f1 = new File("conf/" + PROPERTY_FILENAME);
                pc = new PropertiesConfiguration(f1);
                pc.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.addConfiguration(pc);
                log.info("Added file to configuration source: " + f1.getAbsolutePath());

                // Override with file in "/etc/ejbca/conf/extra, this is prio 3
                File f2 = new File("/etc/ejbca/conf/extra/" + PROPERTY_FILENAME);
                pc = new PropertiesConfiguration(f2);
                pc.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.addConfiguration(pc);
                log.info("Added file to configuration source: " + f2.getAbsolutePath());
            }

            // Default values build into war file, this is last prio used if no of the other sources override this
            URL url = ExtraConfiguration.class.getResource("/" + PROPERTY_FILENAME);
            pc = new PropertiesConfiguration(url);
            config.addConfiguration(pc);
            log.info("Added url to configuration source: " + url);

            log.info("Allow external re-configuration: " + allowexternal);
            // Test
            log.debug("Using keystore path (1): " + config.getString(SCEPKEYSTOREPATH + ".1"));
            //log.debug("Using keystore pwd (1): "+config.getString(SCEPKEYSTOREPWD+".1"));
            //log.debug("Using authPwd: "+config.getString(SCEPAUTHPWD));
            log.debug("Using certificate profile: " + config.getString(SCEPCERTPROFILEKEY));
            log.debug("Using entity profile: " + config.getString(SCEPENTITYPROFILEKEY));
            log.debug("Using default CA: " + config.getString(SCEPDEFAULTCA));
            log.debug("Create or edit user: " + config.getBoolean(SCEPEDITUSER));
            log.debug("Mapping for CN=Scep CA,O=EJBCA Sample,C=SE: "
                    + config.getString("CN=Scep CA,O=EJBCA Sample,C=SE"));
        } catch (ConfigurationException e) {
            log.error("Error intializing ExtRA Configuration: ", e);
        }
    }
    return config;
}

From source file:org.glite.security.voms.admin.configuration.VOMSConfiguration.java

private VOMSConfiguration(ServletContext ctxt) {

    this.context = ctxt;

    config = new CompositeConfiguration();

    loadVersionProperties();//www.  j  a v a 2s.c  o  m
    loadConfDir();
    loadHostAndPort();

    if (context != null) {

        context = ctxt;

        loadVOName();
        loadServiceProperties();
        loadServiceCredentials();

    } else {

        config.addConfiguration(new SystemConfiguration());

    }

    log.debug("VOMS-Admin configuration loaded!");

}

From source file:org.glite.security.voms.admin.configuration.VOMSConfiguration.java

private void loadVOName() {

    SystemConfiguration systemConfig = new SystemConfiguration();

    if (!config.containsKey("VO_NAME")) {

        if (context.getInitParameter("VO_NAME") != null) {
            log.debug("Setting VO name from init parameter: {}", context.getInitParameter("VO_NAME"));

            config.setProperty(VOMSConfigurationConstants.VO_NAME, context.getInitParameter("VO_NAME"));

        }/*from   w  ww.j ava 2s  .co m*/

        if (!config.containsKey(VOMSConfigurationConstants.VO_NAME)) {
            throw new VOMSConfigurationException("VO_NAME property not found!");
        }

    } else {

        config.setProperty(VOMSConfigurationConstants.VO_NAME, config.getProperty("VO_NAME"));

    }
}

From source file:org.jhub1.agent.configuration.PropertiesImpl.java

public PropertiesImpl() throws ConfigurationException {
    reloadingStrategy = new ManagedReloadingStrategy();
    config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new PropertiesConfiguration("agent.properties"));
    config.addConfiguration(new PropertiesConfiguration("agent.internal.properties"));
    try {/*  w  w w.j a  v a  2  s.co m*/
        XMLConfiguration fromFile = new XMLConfiguration("settings.xml");
        fromFile.setReloadingStrategy(reloadingStrategy);
        reloadFlag = true;
        config.addConfiguration(fromFile);
    } catch (ConfigurationException ce) {
        log.error("Problem with loading custom configuration: " + ce.getMessage());
    }
    config.addConfiguration(new XMLConfiguration("settings.default.xml"));
}

From source file:org.mifos.dmt.configuration.DMTPropertiesLoader.java

private DMTPropertiesLoader() throws ConfigurationException {
    config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new EnvironmentConfiguration());
    String confPath = config.getString("DMT_CONF");
    if (confPath == null || confPath == "" || confPath.equalsIgnoreCase("")) {
        throw new ConfigurationException("DMT_CONF not defined");
    }/*from   w w w. ja  va  2s.co  m*/
    config.addConfiguration(new PropertiesConfiguration(confPath + "\\dmt.custom.properties"));
    config.addConfiguration(new PropertiesConfiguration("dmt.properties"));
    config.setThrowExceptionOnMissing(true);
}

From source file:org.mozilla.testopia.transport.TestopiaXmlRpcClient.java

/**
 * Creates a composite configuration from testopiajavadriver.properties and 
 * from the system configuration. Properties from the properties file 
 * override the system properties.//from  w  w  w.j  a  va 2 s  . c o m
 * @return CompositeConfiguration
 */
private CompositeConfiguration createCompositeConfiguration() {
    CompositeConfiguration configuration = new CompositeConfiguration();
    configuration.addConfiguration(new SystemConfiguration());
    try {
        configuration.addConfiguration(new PropertiesConfiguration("testopiajavadriver.properties"));
    } catch (ConfigurationException ce) {
        this.debug(ce);
    }
    return configuration;
}

From source file:org.msjs.config.MsjsConfiguration.java

private void loadSystemConfig() {
    SystemConfiguration sysConfig = new SystemConfiguration();
    Iterator<String> keys = sysConfig.getKeys("msjs");
    while (keys.hasNext()) {
        String key = keys.next();
        setProperty(key, sysConfig.getProperty(key));
    }/*w  w  w  . ja  v a 2 s  . co  m*/
}

From source file:org.neo4j.server.configuration.PropertyFileConfigurator.java

@Override
public Configuration configuration() {
    return serverConfiguration == null ? new SystemConfiguration() : serverConfiguration;
}

From source file:org.neo4j.server.webadmin.rest.MonitorServiceDocTest.java

@Before
public void setUp() throws Exception {
    database = new WrappedDatabase(
            (InternalAbstractGraphDatabase) new TestGraphDatabaseFactory().newImpermanentDatabase());

    rrdDb = new RrdFactory(new SystemConfiguration(), DEV_NULL).createRrdDbAndSampler(database, this);

    output = new EntityOutputFormat(new JsonFormat(), URI.create("http://peteriscool.com:6666/"), null);
    monitorService = new MonitorService(rrdDb.get(), output);
}

From source file:org.neo4j.server.webadmin.rest.MonitorServiceTest.java

@Before
public void setUp() throws Exception {
    database = new Database(new ImpermanentGraphDatabase());

    rrdDb = new RrdFactory(new SystemConfiguration()).createRrdDbAndSampler(database, this);

    output = new EntityOutputFormat(new JsonFormat(), URI.create("http://peteriscool.com:6666/"), null);
    monitorService = new MonitorService(rrdDb, output);
}