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


Java FileBasedConfigurationBuilder.getConfiguration方法代码示例

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


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

示例1: showBoard

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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.builder.FileBasedConfigurationBuilder; //导入方法依赖的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.builder.FileBasedConfigurationBuilder; //导入方法依赖的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: createConfiguration

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的package包/类
private static FileBasedConfiguration createConfiguration(Reader reader)
    throws ConfigurationException {
  if (reader == null) {
    throw new NullPointerException("reader: null");
  }

  FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
      new FileBasedConfigurationBuilder<FileBasedConfiguration>(XMLConfiguration.class)
          .configure(new Parameters().xml());

  FileBasedConfiguration fileBasedConfiguration = builder.getConfiguration();

  FileHandler handler = new FileHandler(fileBasedConfiguration);
  handler.load(reader);
  return fileBasedConfiguration;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:17,代码来源:XmlConfigurationSource.java

示例5: createXmlConfiguration

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的package包/类
protected Pair<XMLConfiguration, URL> createXmlConfiguration(String fileName) {
    List<Lookup> lookups = Arrays.asList(new SystemPropertiesLookup(), new HomeLookup(), new ConfigLookup());

    Parameters params = new Parameters();
    FallbackBasePathLocationStrategy locationStrategy =
            new FallbackBasePathLocationStrategy(FileLocatorUtils.DEFAULT_LOCATION_STRATEGY, home);
    FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class)
            .configure(params.xml().setDefaultLookups(lookups).setLocationStrategy(locationStrategy).setFileName(fileName)
                    .setSchemaValidation(true).setEntityResolver(new ResourceSchemaResolver()));

    try {
        XMLConfiguration xmlConfiguration = builder.getConfiguration();

        return new ImmutablePair<>(xmlConfiguration, locationStrategy.getLocatedUrl());
    } catch (ConfigurationException e) {
        throw new ConfigException(e);
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:19,代码来源:DefaultConfigurationManager.java

示例6: Config

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例7: buildFromConfig

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例8: testOverride

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例9: modifyAndSave

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例10: loadConfigurationManager

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例11: ConfigurationManager

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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

示例12: loadConfiguration

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的package包/类
private static Configuration loadConfiguration() throws IOException, ConfigurationException {
    Configurations configurations = new Configurations();
    File file = Constants.SETTINGS_FILE_XML;
    if (!file.exists()) {
        XMLConfiguration tempConfiguration = new XMLConfiguration();
        new FileHandler(tempConfiguration).save(file);
    }
    FileBasedConfigurationBuilder<XMLConfiguration> builder = configurations.xmlBuilder(file);
    builder.setAutoSave(true);
    return builder.getConfiguration();
}
 
开发者ID:helios-decompiler,项目名称:standalone-app,代码行数:12,代码来源:Helios.java

示例13: readExtensionNames

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的package包/类
private Set<String> readExtensionNames(final File folder) throws Exception {
    try (final InputStream extensionsXML = getClass().getResourceAsStream("extensions.xml")) {
        new File(folder, "bin/platform").mkdirs();
        Files.copy(extensionsXML, new File(folder, "bin/platform/extensions.xml").toPath());
    }

    final File hybrisPlatformDirectory = new File(folder, "bin/platform");
    final File platformExtensionsFile = new File(hybrisPlatformDirectory, "extensions.xml");
    final FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(
            XMLConfiguration.class).configure(new Parameters().xml().setFile(platformExtensionsFile));
    final XMLConfiguration platformExtensionsConfiguration = builder.getConfiguration();
    final List<String> extensionNames = Lists
            .newArrayList(platformExtensionsConfiguration.getList(String.class, "extensions.extension[@name]"));
    return new HashSet<>(extensionNames);
}
 
开发者ID:AGETO,项目名称:hybris-maven-plugin,代码行数:16,代码来源:ExtensionFactoryTest.java

示例14: Config

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的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("pdf2xml.properties").setLocationStrategy(new ClasspathLocationStrategy()));
		configuration = builder.getConfiguration();
	} catch (ConfigurationException e) {
		LOG.error(e, e);
	}
}
 
开发者ID:TekstoSense,项目名称:pdf-segmenter,代码行数:15,代码来源:Config.java

示例15: getHeapSpankJarConfiguration

import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; //导入方法依赖的package包/类
private Configuration getHeapSpankJarConfiguration() throws ConfigurationException {
	Parameters params = new Parameters();
	FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
	    new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
	    	.configure(params.properties()
	        .setFileName(PROPERTIES_FILE)
	        .setLocationStrategy(new ClasspathLocationStrategy())
	        );		
	Configuration config = builder.getConfiguration();		
	return config;
}
 
开发者ID:eostermueller,项目名称:heapSpank,代码行数:12,代码来源:ApacheCommonsConfigFile.java


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