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.apache.bookkeeper.conf.AbstractConfiguration.java

protected AbstractConfiguration() {
    super();//from w  ww  .  j  a va  2 s.co m
    if (READ_SYSTEM_PROPERTIES) {
        // add configuration for system properties
        addConfiguration(new SystemConfiguration());
    }
}

From source file:org.apache.bookkeeper.stream.conf.StreamConfiguration.java

public StreamConfiguration() {
    super();
    addConfiguration(new SystemConfiguration());
}

From source file:org.apache.falcon.regression.core.util.Config.java

private void initConfig(String propFileName) throws ConfigurationException {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    LOGGER.info("Going to add properties from system properties.");
    compositeConfiguration.addConfiguration(new SystemConfiguration());

    LOGGER.info("Going to read properties from: " + propFileName);
    final PropertiesConfiguration merlinConfig = new PropertiesConfiguration(
            Config.class.getResource("/" + propFileName));
    //if changed configuration will be reloaded within 2 min
    final FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
    reloadingStrategy.setRefreshDelay(2 * 60 * 1000);
    merlinConfig.setReloadingStrategy(reloadingStrategy);
    compositeConfiguration.addConfiguration(merlinConfig);
    this.confObj = compositeConfiguration;
}

From source file:org.apache.isis.objectstore.nosql.db.file.server.FileServer.java

public FileServer() {
    org.apache.log4j.PropertyConfigurator.configure("config/logging.properties");

    try {/* w w  w. j a  v  a 2 s  .  c  o  m*/
        config = new CompositeConfiguration();
        config.addConfiguration(new SystemConfiguration());
        config.addConfiguration(new PropertiesConfiguration("config/server.properties"));

        final String data = config.getString("fileserver.data");
        final String services = config.getString("fileserver.services");
        final String logs = config.getString("fileserver.logs");
        final String archive = config.getString("fileserver.archive");

        Util.setDirectory(data, services, logs, archive);
        server = new FileServerProcessor();
    } catch (final ConfigurationException e) {
        LOG.error("configuration failure", e);
        System.out.println(e.getMessage());
        System.exit(0);
    }
}

From source file:org.apache.isis.runtimes.dflt.objectstores.nosql.db.file.server.FileServer.java

public FileServer() {
    PropertyConfigurator.configure("config/logging.properties");

    try {//from  w w w  .  ja v  a 2s  .co m
        config = new CompositeConfiguration();
        config.addConfiguration(new SystemConfiguration());
        config.addConfiguration(new PropertiesConfiguration("config/server.properties"));

        final String data = config.getString("fileserver.data");
        final String services = config.getString("fileserver.services");
        final String logs = config.getString("fileserver.logs");
        final String archive = config.getString("fileserver.archive");

        Util.setDirectory(data, services, logs, archive);
        server = new FileServerProcessor();
    } catch (final ConfigurationException e) {
        LOG.error("configuration failure", e);
        System.out.println(e.getMessage());
        System.exit(0);
    }
}

From source file:org.apache.juddi.config.AppConfig.java

/**
 * Does the actual work of reading the configuration from System
 * Properties and/or juddiv3.properties file. When the juddiv3.properties
 * file is updated the file will be reloaded. By default the reloadDelay is
 * set to 1 second to prevent excessive date stamp checking.
 *//*ww  w.  ja va  2s .c o m*/
private void loadConfiguration() throws ConfigurationException {
    //Properties from system properties
    CompositeConfiguration compositeConfig = new CompositeConfiguration();
    compositeConfig.addConfiguration(new SystemConfiguration());
    //Properties from file
    //changed 7-19-2013 AO for JUDDI-627
    XMLConfiguration propConfig = null;
    final String filename = System.getProperty(JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY);
    if (filename != null) {
        propConfig = new XMLConfiguration(filename);
        try {
            loadedFrom = new File(filename).toURI().toURL();
            //   propConfig = new PropertiesConfiguration(filename);
        } catch (MalformedURLException ex) {
            try {
                loadedFrom = new URL("file://" + filename);
            } catch (MalformedURLException ex1) {
                log.warn("unable to get an absolute path to " + filename
                        + ". This may be ignorable if everything works properly.", ex1);
            }
        }
    } else {
        //propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
        propConfig = new XMLConfiguration(JUDDI_PROPERTIES);
        loadedFrom = ClassUtil.getResource(JUDDI_PROPERTIES, this.getClass());
    }
    //Hey! this may break things
    propConfig.setAutoSave(true);

    log.info("Reading from properties file:  " + loadedFrom);
    long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
    log.debug("Setting refreshDelay to " + refreshDelay);
    FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
    fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
    propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
    compositeConfig.addConfiguration(propConfig);

    Properties properties = new Properties();
    if ("Hibernate".equals(propConfig.getString(Property.PERSISTENCE_PROVIDER))) {
        if (propConfig.containsKey(Property.DATASOURCE))
            properties.put("hibernate.connection.datasource", propConfig.getString(Property.DATASOURCE));
        if (propConfig.containsKey(Property.HBM_DDL_AUTO))
            properties.put("hibernate.hbm2ddl.auto", propConfig.getString(Property.HBM_DDL_AUTO));
        if (propConfig.containsKey(Property.DEFAULT_SCHEMA))
            properties.put("hibernate.default_schema", propConfig.getString(Property.DEFAULT_SCHEMA));
        if (propConfig.containsKey(Property.HIBERNATE_DIALECT))
            properties.put("hibernate.dialect", propConfig.getString(Property.HIBERNATE_DIALECT));
    }
    // initialize the entityManagerFactory.
    PersistenceManager.initializeEntityManagerFactory(propConfig.getString(Property.JUDDI_PERSISTENCEUNIT_NAME),
            properties);
    // Properties from the persistence layer 
    MapConfiguration persistentConfig = new MapConfiguration(getPersistentConfiguration(compositeConfig));

    compositeConfig.addConfiguration(persistentConfig);
    //Making the new configuration globally accessible.
    config = compositeConfig;
}

From source file:org.apache.juddi.v3.client.config.ClientConfig.java

/**
 * Does the actual work of reading the configuration from System
 * Properties and/or uddi.xml file. When the uddi.xml
 * file is updated the file will be reloaded. By default the reloadDelay is
 * set to 1 second to prevent excessive date stamp checking.
 *///from   w  ww. ja  va2 s  . c  om
private void loadConfiguration(String configurationFile, Properties properties) throws ConfigurationException {
    //Properties from system properties
    CompositeConfiguration compositeConfig = new CompositeConfiguration();
    compositeConfig.addConfiguration(new SystemConfiguration());
    //Properties from XML file
    if (System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY) != null) {
        log.info("Using system property config override");
        configurationFile = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
    }
    XMLConfiguration xmlConfig = null;
    if (configurationFile != null) {
        xmlConfig = new XMLConfiguration(configurationFile);
    } else {
        final String filename = System.getProperty(UDDI_CONFIG_FILENAME_PROPERTY);
        if (filename != null) {
            xmlConfig = new XMLConfiguration(filename);
        } else {
            xmlConfig = new XMLConfiguration(DEFAULT_UDDI_CONFIG);
        }
    }
    log.info("Reading UDDI Client properties file " + xmlConfig.getBasePath() + " use -D"
            + UDDI_CONFIG_FILENAME_PROPERTY + " to override");
    this.configurationFile = xmlConfig.getBasePath();
    long refreshDelay = xmlConfig.getLong(Property.UDDI_RELOAD_DELAY, 1000l);
    log.debug("Setting refreshDelay to " + refreshDelay);
    FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
    fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
    xmlConfig.setReloadingStrategy(fileChangedReloadingStrategy);
    compositeConfig.addConfiguration(xmlConfig);
    //Making the new configuration globally accessible.
    config = compositeConfig;
    readConfig(properties);
}

From source file:org.apache.log.extractor.App.java

private void initConfiguration() throws ConfigurationException {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    compositeConfiguration.addConfiguration(new SystemConfiguration());
    compositeConfiguration.addConfiguration(new PropertiesConfiguration("logExtractor.properties"));
    config = compositeConfiguration;/*  w w  w .j a  v a 2 s.com*/
}

From source file:org.apache.qpid.server.configuration.XmlConfigurationUtilities.java

public final static Configuration flatConfig(File file) throws ConfigurationException {
    // We have to override the interpolate methods so that
    // interpolation takes place across the entirety of the
    // composite configuration. Without doing this each
    // configuration object only interpolates variables defined
    // inside itself.
    final MyConfiguration conf = new MyConfiguration();
    conf.addConfiguration(new SystemConfiguration() {
        protected String interpolate(String o) {
            return conf.interpolate(o);
        }/*from ww w.j  a va2s . com*/
    });
    conf.addConfiguration(new XMLConfiguration(file) {
        protected String interpolate(String o) {
            return conf.interpolate(o);
        }
    });
    return conf;
}

From source file:org.apache.qpid.server.model.adapter.VirtualHostAdapter.java

private VirtualHostConfiguration createVirtualHostConfiguration(String virtualHostName)
        throws ConfigurationException {
    VirtualHostConfiguration configuration;
    String configurationFile = (String) getAttribute(CONFIG_PATH);
    if (configurationFile == null) {
        final MyConfiguration basicConfiguration = new MyConfiguration();
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.addProperty("store.type", (String) getAttribute(STORE_TYPE));
        config.addProperty("store.environment-path", (String) getAttribute(STORE_PATH));
        basicConfiguration.addConfiguration(config);

        CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
        compositeConfiguration.addConfiguration(new SystemConfiguration());
        compositeConfiguration.addConfiguration(basicConfiguration);
        configuration = new VirtualHostConfiguration(virtualHostName, compositeConfiguration, _broker);
    } else {/*from ww  w .  ja va2s. c o m*/
        configuration = new VirtualHostConfiguration(virtualHostName, new File(configurationFile), _broker);
    }
    return configuration;
}