List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration()
From source file:io.s4.meter.generator.GeneratorModule.java
/** * Loads properties./*from w w w . j a v a2 s . c om*/ * * @param binder * the Guice binder. */ private void loadProperties(Binder binder) { try { InputStream is = this.getClass().getResourceAsStream("/generator.properties"); config = new PropertiesConfiguration(); config.load(is); // System.out.println(ConfigurationUtils.toString(config)); logger.info(ConfigurationUtils.toString(config)); /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:com.kylinolap.rest.service.AdminService.java
/** * Get Java Env info as string//www. ja v a 2 s . c o m * * @return */ @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN) public String getEnv() { logger.debug("Get Kylin Runtime environment"); PropertiesConfiguration tempConfig = new PropertiesConfiguration(); // Add Java Env try { String content = ""; ByteArrayOutputStream baos = new ByteArrayOutputStream(); // env Map<String, String> env = System.getenv(); for (String envName : env.keySet()) { tempConfig.addProperty(envName, env.get(envName)); } // properties Properties properteis = System.getProperties(); for (Object propName : properteis.keySet()) { tempConfig.setProperty((String) propName, properteis.get(propName)); } // do save tempConfig.save(baos); content = baos.toString(); return content; } catch (ConfigurationException e) { logger.debug("Failed to get Kylin Runtime env", e); throw new InternalErrorException("Failed to get Kylin env Config", e); } }
From source file:net.sourceforge.fullsync.impl.ConfigurationPreferences.java
/** * constructor.//from ww w .jav a 2s . co m * * @param configFile * config file name */ public ConfigurationPreferences(final String configFile) { this.config = new PropertiesConfiguration(); try { File file = new File(configFile); config.setFile(file); if (file.exists()) { config.load(); } lastFullSyncVersion = config.getString("FullSync.Version", ""); } catch (ConfigurationException e) { ExceptionHandler.reportException(e); } catch (FactoryConfigurationError e) { ExceptionHandler.reportException(e); } if (null == lastFullSyncVersion) { lastFullSyncVersion = ""; } }
From source file:com.linkedin.pinot.queries.TestingServerPropertiesBuilder.java
public PropertiesConfiguration build() throws IOException { final File file = new File("/tmp/" + TestingServerPropertiesBuilder.class.toString()); if (file.exists()) { FileUtils.deleteDirectory(file); }//w w w.jav a 2 s .co m file.mkdir(); final File bootsDir = new File(file, "bootstrap"); final File dataDir = new File(file, "data"); bootsDir.mkdir(); dataDir.mkdir(); final PropertiesConfiguration config = new PropertiesConfiguration(); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "id"), "0"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "bootstrap.segment.dir"), bootsDir.getAbsolutePath()); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "dataDir"), dataDir.getAbsolutePath()); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "bootstrap.segment.dir"), "0"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "data.manager.class"), "com.linkedin.pinot.core.data.manager.InstanceDataManager"); config.addProperty( StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "segment.metadata.loader.class"), "com.linkedin.pinot.core.indexsegment.columnar.ColumnarSegmentMetadataLoader"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, "tableName"), StringUtils.join(tableNames, ",")); for (final String table : tableNames) { config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "dataManagerType"), "offline"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "readMode"), "heap"); config.addProperty( StringUtil.join(".", PINOT_SERVER_PREFIX, INSTANCE_PREFIC, table, "numQueryExecutorThreads"), "50"); } config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, EXECUTOR_PREFIX, "class"), "com.linkedin.pinot.core.query.executor.ServerQueryExecutor"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, EXECUTOR_PREFIX, "timeout"), "150000"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, "requestHandlerFactory.class"), "com.linkedin.pinot.server.request.SimpleRequestHandlerFactory"); config.addProperty(StringUtil.join(".", PINOT_SERVER_PREFIX, "netty.port"), "8882"); config.setDelimiterParsingDisabled(true); final Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); System.out.println(key + " : " + config.getProperty(key)); } return config; }
From source file:com.germinus.easyconf.ConfigurationLearningTest.java
public void testSubset() { Configuration conf = new PropertiesConfiguration(); conf.setProperty("prefix.key", "value"); Configuration subset = conf.subset("prefix"); assertTrue("The subset functionality does not work", subset.containsKey("key")); }
From source file:com.moneydance.modules.features.importlist.util.Settings.java
Settings() { final AbstractFileConfiguration abstractFileConfiguration = new PropertiesConfiguration(); try {/*from w ww . j a va2s .com*/ InputStream inputStream = Helper.getInputStreamFromResource(PROPERTIES_RESOURCE); abstractFileConfiguration.load(inputStream); } catch (ConfigurationException e) { throw new IllegalStateException(e.getMessage(), e); } this.config = abstractFileConfiguration; }
From source file:com.jf.commons.datamodels.hrm.classifiers.City.java
/** * Create table and insert predefine data * /*from ww w .ja va 2s.com*/ * @param dao * @throws Exception */ public static void generateData(Dao<City, Long> dao) throws Exception { // create table if not exists TableUtils.createTableIfNotExists(dao.getConnectionSource(), City.class); // insert predefine data PropertiesConfiguration cfg = new PropertiesConfiguration(); cfg.load(new InputStreamReader(City.class.getResourceAsStream("cities.properties"), "UTF-8")); for (String c : cfg.getStringArray("cities")) { String[] city = c.split(":"); City m = new City(); m.setNew(true); m.setName(city[0].trim()); m.setNamePrefix(city[1].trim()); m.setCreator("admin"); dao.create(m); } }
From source file:com.nesscomputing.config.TestPrefix.java
@Test public void testOverride() { Assert.assertThat(cfg, is(notNullValue())); PropertiesConfiguration pc = new PropertiesConfiguration(); pc.setProperty("prefix.of.three.string-null-value", "NULL"); pc.setProperty("prefix.of.three.string-value", "another test value"); Config c2 = Config.getOverriddenConfig(cfg, pc); final Configuration config = c2.getConfiguration("prefix.of.three"); Assert.assertThat(config, is(notNullValue())); final String s_cfg1 = config.getString("string-null-value"); Assert.assertThat(s_cfg1, is("NULL")); final String s_cfg2 = config.getString("string-value"); Assert.assertThat(s_cfg2, is("another test value")); }
From source file:io.s4.comm.Module.java
private void loadProperties(Binder binder) { try {/*from www . j a v a2s . co m*/ InputStream is = this.getClass().getResourceAsStream("/s4-comm.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:io.s4.example.counter.Module.java
private void loadProperties(Binder binder) { try {/*from ww w . j a va 2 s . c o m*/ InputStream is = this.getClass().getResourceAsStream("/s4-piper-example.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }