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


Java PropertiesConfiguration类代码示例

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


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

示例1: showBoard

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
@Override
public void showBoard() {
    File paramFile = new File("config/mainboardfx.properties");
    try {
        final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
            PropertiesConfiguration.class)
            .configure(
                new FileBasedBuilderParametersImpl().setFile(paramFile).setEncoding("utf8"));
        cfg = builder.getConfiguration();
    } catch (ConfigurationException ex) {
        QLog.l().logger()
            .error("Не загружен файл конфигурации " + paramFile.getAbsolutePath(), ex);
        throw new ServerException(
            "Не загружен файл конфигурации " + paramFile.getAbsolutePath());
    }

    super.showBoard();
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:19,代码来源:OrangeMainboard.java

示例2: savePropertyForStandaloneProfile

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Save property for standalone profile.
 *
 * @param pair the pair
 */
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
    try {
        final File file = getStandaloneProfileConfigurationDirectory();
        final Parameters params = new Parameters();

        final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                        .configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));

        final Configuration config = builder.getConfiguration();
        config.setProperty(pair.getKey(), pair.getValue());
        builder.save();
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:CasConfigurationPropertiesEnvironmentManager.java

示例3: createPropertiesConfiguration

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
private static FileBasedConfiguration createPropertiesConfiguration(Reader reader)
    throws ConfigurationException, IOException {
  if (reader == null) {
    throw new NullPointerException("reader: null");
  }

  FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
      new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
          .configure(new Parameters()
              .properties()
              .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

  FileBasedConfiguration config = builder.getConfiguration();
  config.read(reader);
  return config;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:17,代码来源:PropertiesConfigurationSource.java

示例4: Config

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Instantiates a new config.
 */
private Config() {
	try {
		Parameters params = new Parameters();
		FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
				PropertiesConfiguration.class);
		builder.configure(params.fileBased().setFileName("nlp.properties")
				.setLocationStrategy(new ClasspathLocationStrategy()));
		configuration = builder.getConfiguration();
		// Adding TEKSTO_HOME path to Configuration
		String homePath = System.getenv(TEKSTO_HOME);
		if (homePath != null && !homePath.isEmpty()) {
			configuration.setProperty(MODEL_PATH, homePath + "/Models");
		}
	} catch (ConfigurationException e) {
		LOG.error(e, e);
	}
}
 
开发者ID:TekstoSense,项目名称:opennlp-enhancer,代码行数:21,代码来源:Config.java

示例5: buildFromConfig

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Builds the Configuration object from the properties file (apache commons
 * properties file format). <br>
 * The values provided in the config file will be overwritten environment
 * variables (if present)
 * 
 * List of the properties <br>
 * loginsight.host = host name <br>
 * loginsight.port = port number <br>
 * loginsight.user = User name <br>
 * loginsight.password = password <br>
 * loginsight.ingestion.agentId = agentId <br>
 * loginsight.connection.scheme = http protocol scheme <br>
 * loginsight.ingestion.port = Ingestion port number <br>
 * 
 * @param configFileName
 *            Name of the config file to read
 * @return Newly created Configuration object
 */
public static Configuration buildFromConfig(String configFileName) {
	try {
		List<FileLocationStrategy> subs = Arrays.asList(new ProvidedURLLocationStrategy(),
				new FileSystemLocationStrategy(), new ClasspathLocationStrategy());
		FileLocationStrategy strategy = new CombinedLocationStrategy(subs);

		FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(
				PropertiesConfiguration.class).configure(
						new Parameters().fileBased().setLocationStrategy(strategy).setFileName(configFileName));
		PropertiesConfiguration propConfig = builder.getConfiguration();
		Map<String, String> propMap = new HashMap<String, String>();
		Iterator<String> keys = propConfig.getKeys();
		keys.forEachRemaining(key -> {
			logger.info(key + ":" + propConfig.getString(key));
			propMap.put(key, propConfig.getString(key));
		});
		Configuration config = Configuration.buildConfig(propMap);
		config.loadFromEnv();
		return config;
	} catch (ConfigurationException e1) {
		throw new RuntimeException("Unable to load config", e1);
	}
}
 
开发者ID:vmware,项目名称:loginsight-java-api,代码行数:43,代码来源:Configuration.java

示例6: testOverride

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
@Test
public void testOverride() {

    Parameters params = new Parameters();
    FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
            new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                    .configure(params.properties()
                            .setFileName("file.properties"));
    Configuration config = null;
    try {
        config = builder.getConfiguration();
        config.setProperty("somekey", "somevalue");
        builder.save();
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:bejondshao,项目名称:personal,代码行数:18,代码来源:PropertyOverrideTest.java

示例7: modifyAndSave

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
/**
 * Applies the specified function to the specified set of parameters contained in the input file.
 *
 * @param input The specified name of file to encrypt
 * @param mustBeModified the specified set of parameters
 * @param function the specified function to apply to the set of specified parameters
 */
private void modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function) {
    Path inputFilePath = Paths.get(input);
    if (Files.exists(inputFilePath) && Files.isRegularFile(inputFilePath) && Files.isReadable(inputFilePath)) {
        try {
            Parameters params = new Parameters();
            FileBasedConfigurationBuilder<PropertiesConfiguration> builder = //
                    new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) //
                            .configure(params.fileBased() //
                                    .setFile(inputFilePath.toFile())); //
            PropertiesConfiguration config = builder.getConfiguration();
            mustBeModified.stream().filter(config::containsKey)
                    .forEach(key -> config.setProperty(key, function.apply(config.getString(key))));

            builder.save();
        } catch (ConfigurationException e) {
            LOGGER.error("unable to read {} {}", input, e);
        }
    } else {
        LOGGER.debug("No readable file at {}", input);
    }
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:29,代码来源:PropertiesEncryption.java

示例8: AliceRecognition

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
private AliceRecognition()
{
	try
	{
		CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
		config.addConfiguration(new SystemConfiguration());
		config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			    					  .configure(new Parameters().properties().setFileName(ALICE_PROPERTIES)).getConfiguration());
			
		this.enabled = config.getBoolean(ALICE_ENABLED, false);
		String url = config.getString(ALICE_SERVICE_URL, null); 
		String accessToken = config.getString(ALICE_ACCESS_TOKEN, null); 
		String command = config.getString(ALICE_COMMAND, null); 
	
		if(enabled && !StringUtils.isEmpty(url) && !StringUtils.isEmpty(accessToken))
		{
			this.client = new AliceClient(url, command);
			this.client.setAuthToken(accessToken);
			this.enabled = this.client.isAvailable();
		}
	}
	catch (Exception e) 
	{
		LOGGER.error("Unable to initialize Alice: " + e.getMessage());
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:27,代码来源:AliceRecognition.java

示例9: init

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getHotkeysFile()));
	config = builder.getConfiguration();
	loadHotkeys();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:HotkeyController.java

示例10: init

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
public static void init(String worldLocation) throws ConfigurationException {
	log.debug("World Location for properties: " + worldLocation);
	configManager = new Configurations();
	if(worldLocation == null){
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName(defaultWorldPropertiesLocation));
	}else
	{
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
				.configure(configManager.getParameters().fileBased().setFileName(worldLocation));
	}
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:14,代码来源:WorldConfig.java

示例11: init

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getAppPropFile()));
	
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:AppConfig.java

示例12: firstInit

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
public static void firstInit() throws Exception{
	configManager = new Configurations();
	
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName("src/main/resources/app.properties"));
	
	config = builder.getConfiguration();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:9,代码来源:AppConfig.java

示例13: loadConfigurationManager

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
private void loadConfigurationManager() {
    log.trace(() -> "Initializing configuration cache.");

    @NotNull Parameters params = new Parameters();

    FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
            new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                    .configure(params.properties()
                            .setFileName(PROPERTIES_FILE));

    try {
        this.config = builder.getConfiguration();
    } catch (ConfigurationException e) {
        log.fatal(e);
        throw new RuntimeException("Couldnt load configuration file " + PROPERTIES_FILE);
    }
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:18,代码来源:ConfigurationManager.java

示例14: ConfigurationManager

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
private ConfigurationManager() throws ConfigurationException{
	FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
		new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
			.configure(new Parameters().properties()
			.setFileName(configFilePath)
			.setThrowExceptionOnMissing(true)
			.setListDelimiterHandler(new DefaultListDelimiterHandler(';'))
			.setIncludesAllowed(false));
	config = builder.getConfiguration();
}
 
开发者ID:datancoffee,项目名称:sirocco,代码行数:11,代码来源:ConfigurationManager.java

示例15: getPropertiesConfiguration

import org.apache.commons.configuration2.PropertiesConfiguration; //导入依赖的package包/类
private static PropertiesConfiguration getPropertiesConfiguration(final String fileName) throws ConfigurationException {
	val propertiesPath = ofNullable(ClassLoader.getSystemClassLoader().getResource(fileName))
			.map(URL::getFile)
			.orElseThrow(IllegalArgumentException::new);

	return new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
			.configure(new Parameters().properties().setFile(new File(propertiesPath)))
			.getConfiguration();
}
 
开发者ID:sskorol,项目名称:selenium-camp-17,代码行数:10,代码来源:Configuration.java


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