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

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

Introduction

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

Prototype

public PropertiesConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Creates and loads the extended properties from the specified URL.

Usage

From source file:com.medvision360.medrecord.server.LoggingConfigurationListener.java

public void tryToPreLoadLoggingConfig() {
    String file = System.getProperty(ConfigurationLoader.SYSTEM_PROPERTY_CONFIGFILE);
    if (file == null) {
        try {/*from   w  ww.j av  a 2s  . c o  m*/
            file = ServerProperties.loadFromWar("WEB-INF/com.medvision360.lib.server.properties", "configfile");
        } catch (IOException e) {
            return;
        }
    }

    if (file == null) {
        return;
    }

    Logger logger = LoggerFactory.getLogger(LoggingConfigurationListener.class);
    PropertiesConfiguration config;
    try {
        config = new PropertiesConfiguration(file);
    } catch (org.apache.commons.configuration.ConfigurationException e) {
        return;
    }
    config.setThrowExceptionOnMissing(true);

    ConfigurationWrapper wrapper = new ConfigurationWrapper(logger, config);
    try {
        ConfigureLogger.setupLogging(logger, wrapper);
    } catch (ConfigurationException e) {
        return;
    }
}

From source file:fr.inria.atlanmod.neoemf.data.blueprints.neo4j.option.BlueprintsNeo4jResourceSaveTest.java

@Test
public void testSaveGraphNeo4jResourceNeo4jTypeOption() throws IOException, ConfigurationException {
    Map<String, Object> options = BlueprintsNeo4jOptionsBuilder.newBuilder().asMap();

    resource.save(options);//w ww  .ja  va2s.c om

    File configFile = new File(file() + configFileName);
    assertThat(configFile).exists();

    PropertiesConfiguration configuration = new PropertiesConfiguration(configFile);
    assertConfigurationHasEntry(configuration, BlueprintsNeo4jResourceOptions.GRAPH_TYPE,
            BlueprintsNeo4jResourceOptions.GRAPH_TYPE_NEO4J);
    /*
     * Check the configuration file contains the store_dir property (computed by blueprints at graph creation)
     */
    assertConfigurationHasEntry(configuration, OPTIONS_GRAPH_NEO4J_STORE_DIR, file().getAbsolutePath());

    assertConfigurationHasSize(configuration, 0);
}

From source file:fr.jetoile.hadoopunit.integrationtest.IntegrationBootstrapTest.java

@BeforeClass
public static void setup() throws BootstrapException {
    try {/* w  w w  . j a v  a  2  s . c o  m*/
        configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
    } catch (ConfigurationException e) {
        throw new BootstrapException("bad config", e);
    }

    HadoopBootstrap.INSTANCE.startAll();
}

From source file:at.newmedialab.ldclient.service.LDCache.java

public LDCache(LDCacheProvider ldCacheProvider) {
    log.info("Linked Data Caching Service initialising ...");
    try {/*w w w  .  j  av  a 2 s .com*/
        config = new PropertiesConfiguration("ldclient.properties");
    } catch (ConfigurationException e) {
        log.warn(
                "could not load configuration file ldclient.properties from current directory, home directory, or classpath");
    }

    resourceLocks = new HashMap<URI, Lock>();

    cacheProvider = ldCacheProvider;
    clientService = new LDClient();
    endpointService = new LDEndpoints();
}

From source file:net.nharyes.drivecopy.mod.MainModule.java

@Provides
@Singleton/*from ww  w  .  j a va 2  s  .c om*/
private PropertiesConfiguration providePropertiesConfiguration() {

    PropertiesConfiguration config;

    try {

        // load configuration from file
        config = new PropertiesConfiguration(configFile);

    } catch (ConfigurationException ex) {

        // create empty configuration
        config = new PropertiesConfiguration();
        config.setFileName(configFile);
    }

    return config;
}

From source file:fr.jetoile.hadoopunit.integrationtest.ManualIntegrationBootstrapTest.java

@BeforeClass
public static void setup() throws BootstrapException {
    try {//  w w  w. j  a v  a2 s. c  om
        configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
    } catch (ConfigurationException e) {
        throw new BootstrapException("bad config", e);
    }
}

From source file:common.Parameters.java

public Parameters() {

    PropertiesConfiguration config;/*  w ww . j  av a 2  s  .co m*/
    File file = new File(Constants.LOG4J_PATH);
    if (!file.getAbsoluteFile().exists()) {
        log.error("Invalid log properties file!");
        System.exit(1);
    }
    file = new File(Constants.OBJECT_REPOSITORY_PATH);
    if (!file.getAbsoluteFile().exists()) {
        log.error("Invalid Object properties file!");
        System.exit(1);
    }
    // BasicConfigurator.configure();
    PropertyConfigurator.configure(Constants.LOG4J_PATH);

    try {
        config = new PropertiesConfiguration(Constants.CONFIG_PATH);
        config.getSubstitutor().setEnableSubstitutionInVariables(true);
        setConfig(config);
        checkConfig();
    } catch (ConfigurationException e) {
        log.error("Unable to load config. Config file possibly missing." + e);
        System.exit(1);
    }

}

From source file:fr.jetoile.hadoopunit.component.HiveMetastoreBootstrap.java

private void loadConfig() throws BootstrapException {
    HadoopUtils.setHadoopHome();//w w w. j  a v a 2  s  .  c  o m
    try {
        configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
    } catch (ConfigurationException e) {
        throw new BootstrapException("bad config", e);
    }
    host = configuration.getString(HadoopUnitConfig.HIVE_METASTORE_HOSTNAME_KEY);
    port = configuration.getInt(HadoopUnitConfig.HIVE_METASTORE_PORT_KEY);
    derbyDirectory = configuration.getString(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY);
    scratchDirectory = configuration.getString(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY);
    warehouseDirectory = configuration.getString(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY);

}

From source file:fr.jetoile.hadoopunit.component.ElasticSearchBootstrap.java

private void loadConfig() throws BootstrapException {
    try {/* ww  w .  j a v a2s .  c o  m*/
        configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
    } catch (ConfigurationException e) {
        throw new BootstrapException("bad config", e);
    }

    httpPort = configuration.getInt(HadoopUnitConfig.ELASTICSEARCH_HTTP_PORT_KEY);
    tcpPort = configuration.getInt(HadoopUnitConfig.ELASTICSEARCH_TCP_PORT_KEY);
    ip = configuration.getString(HadoopUnitConfig.ELASTICSEARCH_IP_KEY);
    tmpDir = configuration.getString(HadoopUnitConfig.ELASTICSEARCH_TEMP_DIR_KEY);
    indexName = configuration.getString(HadoopUnitConfig.ELASTICSEARCH_INDEX_NAME);
    clusterName = configuration.getString(HadoopUnitConfig.ELASTICSEARCH_CLUSTER_NAME);
}

From source file:net.audumla.climate.bom.BOMDataLoader.java

private BOMDataLoader() {
    try {/*from  w w  w.j a  v a  2 s .co  m*/
        PropertiesConfiguration config = new PropertiesConfiguration("bomdatacache.properties");
        cache.loadProperties(config);
    } catch (Exception e) {
        LOG.error("Cannot load BOM data loader config", e);
    }

}