当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesConfiguration类代码示例

本文整理汇总了Java中org.apache.commons.configuration.PropertiesConfiguration的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration类的具体用法?Java PropertiesConfiguration怎么用?Java PropertiesConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertiesConfiguration类属于org.apache.commons.configuration包,在下文中一共展示了PropertiesConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadFirst

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Load configuration from a list of files until the first successful load
 * @param conf  the configuration object
 * @param files the list of filenames to try
 * @return  the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
  for (String fname : fileNames) {
    try {
      Configuration cf = new PropertiesConfiguration(fname)
          .interpolatedConfiguration();
      LOG.info("loaded properties from "+ fname);
      LOG.debug(toString(cf));
      MetricsConfig mc = new MetricsConfig(cf, prefix);
      LOG.debug(mc);
      return mc;
    } catch (ConfigurationException e) {
      if (e.getMessage().startsWith("Cannot locate configuration")) {
        continue;
      }
      throw new MetricsConfigException(e);
    }
  }
  LOG.warn("Cannot locate configuration: tried "+
           Joiner.on(",").join(fileNames));
  // default to an empty configuration
  return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:29,代码来源:MetricsConfig.java

示例2: loadData

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
@Override
protected void loadData() {
    // 设定文件初期读入
    try {
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);
        category = languageConf.getString(YiDuConfig.CATEGORY);
    } catch (ConfigurationException e) {
        logger.error(e);
    }
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:21,代码来源:LanguageEditAction.java

示例3: saveRecord

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public void saveRecord() throws Exception {
	if (file.exists()) {
		// file.renameTo(new File(Configs.recordFileName+".bak"));
		file.delete();
	}
	file.createNewFile();
	PropertiesConfiguration record = new PropertiesConfiguration(
			Configs.recordFileName);

	record.addProperty("verifiedUsers", Records.verifiedUsers.toArray());

	// record.addProperty("records", Records.records);

	Object[] usrEntries = Records.records.keySet().toArray();
	record.addProperty("usrEntries", usrEntries);
	for (Object usr : usrEntries) {
		record.addProperty((String) usr, Records.records.get(usr).toArray());
	}
	record.save();

}
 
开发者ID:D0048,项目名称:irc-helper,代码行数:22,代码来源:MyRecord.java

示例4: createDefault

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public void createDefault() throws Exception {
	if (file.exists()) {
		file.renameTo(new File(Enterence.propFileName + ".bak"));
	}
	file.createNewFile();
	PropertiesConfiguration config = new PropertiesConfiguration(
			Enterence.propFileName);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("sudoPwd", Configs.sudoPwd);
	config.setProperty("server", Configs.server);
	config.setProperty("name", Configs.name);
	config.setProperty("pwd", Configs.pwd);
	config.setProperty("channels", Configs.channels);
	config.setProperty("preffix", Configs.preffix);
	config.setProperty("sudoers", Configs.sudoers);
	config.setProperty("recordFileName", Configs.recordFileName);
	config.setProperty("useProxy", Configs.useProxy);
	config.setProperty("Proxy", Configs.Proxy);
	config.save();
}
 
开发者ID:D0048,项目名称:irc-helper,代码行数:21,代码来源:MyConfig.java

示例5: upgrade

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
@Override
public void upgrade(final UpgradeResult result, File tleInstallDir) throws Exception
{
	new PropertyFileModifier(
		new File(new File(tleInstallDir, CONFIG_FOLDER), PropertyFileModifier.MANDATORY_CONFIG))
	{
		@Override
		protected boolean modifyProperties(PropertiesConfiguration props)
		{
			if( props.containsKey("cluster.group.name") )
			{
				result.addLogMessage("Removing cluster.group.name property");
				props.clearProperty("cluster.group.name");
				return true;
			}
			return false;
		}
	}.updateProperties();
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:RemoveClusterGroupName.java

示例6: main

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {		
		if(args.length!=2) {
			System.out.println("Usage: hdt2gremlin <file.hdt> <Gremlin Graph Config File>");
			System.out.println(" The config follows the syntax of gremlins factory Graph.open().");
			System.exit(-1);
		}
		
		// Create Graph
		Configuration p = new PropertiesConfiguration(args[1]);
		try(Graph gremlinGraph = GraphFactory.open(p)){
			
			// Open HDT
			try(HDT hdt = HDTManager.mapHDT("args[0]")){

				// Import HDT into Graph
				StopWatch st = new StopWatch();
				importGraph(hdt, gremlinGraph);
				System.out.println("Took "+st.stopAndShow());
			}
				
//			smallTest(gremlinGraph);
		}
		
		System.exit(0);
	}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:26,代码来源:HDTtoGremlin.java

示例7: normalizeCommands

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
	Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
			TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	found.add(new File("resources/guilds/template.properties"));
	for (File f : found) {
		if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
			PropertiesConfiguration config = new PropertiesConfiguration(f);
			List<String> enabledCommands = config.getList("EnabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			List<String> disabledCommands = config.getList("DisabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			for (Command c : collection) {
				if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
					enabledCommands.add(c.toString());
				}
			}
			config.setProperty("EnabledCommands", enabledCommands);
			config.save();
		}
	}
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:29,代码来源:CommandHandler.java

示例8: loadFirst

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Load configuration from a list of files until the first successful load
 * @param conf  the configuration object
 * @param files the list of filenames to try
 * @return  the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
  for (String fname : fileNames) {
    try {
      Configuration cf = new PropertiesConfiguration(fname)
          .interpolatedConfiguration();
      LOG.info("loaded properties from "+ fname);
      LOG.debug(toString(cf));
      MetricsConfig mc = new MetricsConfig(cf, prefix);
      LOG.debug(mc);
      return mc;
    }
    catch (ConfigurationException e) {
      if (e.getMessage().startsWith("Cannot locate configuration")) {
        continue;
      }
      throw new MetricsConfigException(e);
    }
  }
  LOG.warn("Cannot locate configuration: tried "+
           Joiner.on(",").join(fileNames));
  // default to an empty configuration
  return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:MetricsConfig.java

示例9: loadProperties

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
private PropertiesConfiguration loadProperties() throws ConfigurationException {
    String deploymentProperties = "src/test/resources/deployment-fakeAdapterTest.properties";
    PropertiesConfiguration props = new PropertiesConfiguration(deploymentProperties);
    return props;
    // try {
    // Properties prop = null;
    // Resource res = appContext.getResource(deploymentProperties);
    // InputStream in = res.getInputStream();
    // if (in == null) {
    // LOG.warn("Failed to locate properties file on classpath: " + deploymentProperties);
    // } else {
    // LOG.info("Found '" + deploymentProperties + "' on the classpath");
    // prop = new Properties();
    // prop.load(in);
    // }
    // return prop;
    // } catch (IOException e) {
    // LOG.error("Failed to load properties file '" + deploymentProperties + "'", e);
    // throw new RuntimeException("Failed to initialise from properties file " +
    // deploymentProperties);
    // }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:FakeAdapterTest.java

示例10: testAllTheGetters

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Test all the getters
 */
@Test
public void testAllTheGetters() {
    PropertiesConfiguration props = loadProperties();
    try {
        AdapterConfig config = new AdapterConfig(props);
        Assert.assertEquals("adapterClass", config.getAdapterClass());
        Assert.assertEquals("adapterDir", config.getAdapterDir());
        Assert.assertEquals("authEndpoint", config.getAuthEndpoint());
        Assert.assertEquals(1, config.getCollectThreads());
        Assert.assertEquals("providerId", config.getProviderId());
        Assert.assertEquals("providerName", config.getProviderName());
        Assert.assertEquals("providerType", config.getProviderType());
        Assert.assertEquals(2, config.getSchedulingInterval());


    } catch (AdapterConfigException ex) {
        Assert.fail("Expected it to pass");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:AdapterConfigTest.java

示例11: loadProperties

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Creates a properties config with all the properties set
 *
 * @return
 */
private PropertiesConfiguration loadProperties() {
    PropertiesConfiguration properties = new PropertiesConfiguration();

    properties.addProperty(AdapterConfig.ADAPTER_CLASS, "adapterClass");
    properties.addProperty(AdapterConfig.ADAPTER_DIR, "adapterDir");
    properties.addProperty(AdapterConfig.AUTH_ENDPOINT, "authEndpoint");
    properties.addProperty(AdapterConfig.COLLECT_THREADS, "1");
    properties.addProperty(AdapterConfig.PROVIDER_ID, "providerId");
    properties.addProperty(AdapterConfig.PROVIDER_NAME, "providerName");
    properties.addProperty(AdapterConfig.PROVIDER_TYPE, "providerType");
    properties.addProperty(AdapterConfig.SCHEDULING_INTERVAL, "2");

    properties.addProperty(AdapterConfig.FILE_PATH, "filePath");
    return properties;
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:21,代码来源:AdapterConfigTest.java

示例12: create

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Retrieves {@link CompactionManager}.
 *
 * @param options map of various options keyed by name
 * @return {@link CompactionManager}
 */
public static CompactionManager create(Map<String, String> options) throws Exception {
    final Configuration configuration = new Configuration();
    configuration.addResource(new Path("/etc/hadoop/conf/hdfs-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/core-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/yarn-site.xml"));
    configuration.addResource(new Path("/etc/hadoop/conf/mapred-site.xml"));

    try {
        PropertiesConfiguration config = new PropertiesConfiguration(CONF_PATH);
        DEFAULT_THRESHOLD_IN_BYTES = config.getLong("default.threshold");
    } catch (Exception e) {
        throw new RuntimeException("Exception while loading default threshold in bytes" + e);

    }
    final CompactionCriteria criteria = new CompactionCriteria(options);
    if (StringUtils.isNotBlank(options.get("targetPath"))) {
        return new CompactionManagerImpl(configuration, criteria);
    }
    return new CompactionManagerInPlaceImpl(configuration, criteria);
}
 
开发者ID:ExpediaInceCommercePlatform,项目名称:dataSqueeze,代码行数:27,代码来源:CompactionManagerFactory.java

示例13: ConfigHelper

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public ConfigHelper(String propertyPath) {
    try {
        propertiesConfiguration = new PropertiesConfiguration(propertyPath);
    } catch (Exception e) {
        throw new RuntimeException(
                "Please configure check  file: " + propertyPath);
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:9,代码来源:ConfigHelper.java

示例14: init

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public static void init(String configFilePath) {
    try {
        defultConfigFilePath = configFilePath;
        config = new PropertiesConfiguration(defultConfigFilePath);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JiuzhouSec,项目名称:nightwatch,代码行数:9,代码来源:Configuration.java

示例15: fromPropertiesFile

import org.apache.commons.configuration.PropertiesConfiguration; //导入依赖的package包/类
public static MarketMakerConfiguration fromPropertiesFile(final String fileName) throws ConfigurationException {
    final Configuration configuration = new PropertiesConfiguration(fileName);
    return new MarketMakerConfiguration(
        configuration.getInt(ConfigKey.TIME_SLEEP_SECONDS.getKey()),
        new BigDecimal(configuration.getString(ConfigKey.SPREAD_FRACTION.getKey())),
        configuration.getDouble(ConfigKey.FAIR_VOLATILITY.getKey()),
        configuration.getDouble(ConfigKey.VOLATILITY_SPREAD_FRACTION.getKey()),
        configuration.getInt(ConfigKey.NUM_LEVELS.getKey()),
        configuration.getInt(ConfigKey.QUANTITY_ON_LEVEL.getKey()),
        configuration.getDouble(ConfigKey.DELTA_LIMIT.getKey()),
        configuration.getDouble(ConfigKey.VEGA_LIMIT.getKey())
    );
}
 
开发者ID:quedexnet,项目名称:java-market-maker,代码行数:14,代码来源:MarketMakerConfiguration.java


注:本文中的org.apache.commons.configuration.PropertiesConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。