• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XMLConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createConfiguration

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


示例2: testBalancerStorageSequentialSingle

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testBalancerStorageSequentialSingle() throws Exception {

    SequentialHostBalancer balancer = new SequentialHostBalancer();

    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@balancer]","elm1");

    balancer.setConfiguration(xmlConfiguration);

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    VMwareHost elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm1", "128", "1")));
    elm.setEnabled(true);

    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:27,代码来源:SequentialHostBalancerTest.java


示例3: createXmlConfiguration

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


示例4: createRootConfig

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
protected CommonsConfiguration createRootConfig() {
    MergeCombiner combiner = new MergeCombiner();
    combiner.addListNode(PluginManagerConstants.CFG_PLUGIN);

    CombinedConfiguration cc = new CombinedConfiguration(combiner);

    // Try to add explicit configuration
    if (configurationFilename != null) {
        logger.info("Loading configuration file {}...", configurationFilename);
        Pair<XMLConfiguration, URL> configurationPair = createXmlConfiguration(configurationFilename);

        cc.addConfiguration(configurationPair.getLeft());
        configurationFileUrl = configurationPair.getRight();
    }

    // Add default configuration
    cc.addConfiguration(createXmlConfiguration(ConfigurationConstants.DEFAULT_CONFIG).getLeft());

    // if (configurationFilename != null && logger.isDebugEnabled()) {
    // logger.debug("Initial XML configuration:\n{}", Utils.dumpConfiguration(cc));
    // }

    return new CommonsConfiguration(cc);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:25,代码来源:DefaultConfigurationManager.java


示例5: initMetalPseudonymizerWith

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
private static FramePseudonymizer initMetalPseudonymizerWith(final XMLConfiguration config) throws InvalidKeyException, ClassNotFoundException {
    Processor processor = new Processor();

    List<HierarchicalConfiguration<ImmutableNode>> fields = config.configurationsAt("fields.field");

    for (HierarchicalConfiguration field : fields) {
        List<HierarchicalConfiguration> parameters = field.childConfigurationsAt("algorithm.params");
        List<AlgorithmParameter> parameterList = new ArrayList<>();
        for (HierarchicalConfiguration parameter : parameters) {
            parameterList.add(new AlgorithmParameter(parameter.getString("name"), parameter.getString("value"), Class.forName(parameter.getString("type"))));
        }
        // Add the transformers
        processor.addTransformer(Constraints.CONSTRAINT_MAP.get(field.getString("constraint")), field.getString("name"),
                getParseValueTransformer(ParseValueTransformerFactory.TransformerId.valueOf(field.getString("algorithm.name")), parameterList));
        logger.info("Packets containing " + field.getString("name") +  " will be pseudonymized based on this constraint: " + field.getString("constraint")
                + ", with this algorithm "+ field.getString("algorithm.name") );
    }
    // TODO PEF-43:  Move and change functionality.
    if (config.getBoolean("checksum_reset")) {
        processor.addTransformer(Constraints.IPV4_UDP_DNS, "udpchecksum",new IPv4UDPChecksumCalculator())
                .addTransformer(Constraints.IPV6_UDP_DNS, "udpchecksum", new IPv6UDPChecksumCalculator())
                .addTransformer(Constraints.IPV4_UDP_DNS, "headerchecksum", new IPv4ChecksumCalculator())
                .addTransformer(Constraints.ICMP_DNS, "icmpchecksum", new IPv6UDPChecksumCalculator());
    }
    return new FramePseudonymizer(processor);
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:27,代码来源:LiveCapture.java


示例6: getConfigurationBuilder

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
private FileBasedConfigurationBuilder<XMLConfiguration> getConfigurationBuilder() {
    if (this.configurationBuilder == null) {
        final Parameters params = new Parameters();
        this.configurationBuilder = new FileBasedConfigurationBuilder<XMLConfiguration>(XMLConfiguration.class)
                .configure(params.xml()
                        .setURL(this.getFileName())
                        .setValidating(false));
        this.configurationBuilder.setAutoSave(true);

        // If the file has not yet been written to the disk, as this is the first execution or the file has been deleted (deletion is a legitimate way to "reset to factory settings"), write it now.
        if (this.isConfigurationInitialisationEnabled() && !this.getDefaultFile().exists()) {
            // Reinitialise in order to pick up the newly created file.
            this.propertiesFile = null;
            this.save();
            this.configurationBuilder = null;
            this.getConfigurationBuilder();
        }
    }

    return this.configurationBuilder;
}
 
开发者ID:CloudRacer,项目名称:MockTCPServer,代码行数:22,代码来源:ConfigurationSettings.java


示例7: testBalancer_wrongConfig

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testBalancer_wrongConfig() throws Exception {
    // wrong configuration values should simply be ignored
    EquipartitionHostBalancer balancer = new EquipartitionHostBalancer();
    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@hosts]", "host1,host2,host3,host4,host5");
    xmlConfiguration.addProperty("[@memoryWeight]", "wrong");
    xmlConfiguration.addProperty("[@cpuWeight]", "wrong");
    xmlConfiguration.addProperty("[@vmWeight]", "");
    balancer.setConfiguration(xmlConfiguration);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:12,代码来源:EquipartitionHostBalancerTest.java


示例8: getBalancer

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
private EquipartitionHostBalancer getBalancer(double memWeight,
        double cpuWeight, double vmWeight) throws IOException, ConfigurationException {
    EquipartitionHostBalancer balancer = new EquipartitionHostBalancer();
    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@hosts]", "host1,host2,host3,host4,host5");
    xmlConfiguration.addProperty("[@memoryWeight]", memWeight);
    xmlConfiguration.addProperty("[@cpuWeight]", cpuWeight);
    xmlConfiguration.addProperty("[@vmWeight]", vmWeight);
    balancer.setConfiguration(xmlConfiguration);
    return balancer;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:12,代码来源:EquipartitionHostBalancerTest.java


示例9: getBalancer

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
private EquipartitionStorageBalancer getBalancer(String storages)
    throws ConfigurationException, IOException {
    EquipartitionStorageBalancer balancer = new EquipartitionStorageBalancer();
    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@storage]", storages);
    balancer.setConfiguration(xmlConfiguration);
    return balancer;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:EquipartitionStorageBalancerTest.java


示例10: testSingle

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testSingle() throws Exception {

    SequentialStorageBalancer balancer = new SequentialStorageBalancer();

    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@storage]", "elm1");
    balancer.setConfiguration(xmlConfiguration);

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    VMwareStorage elm = inventory.addStorage("host",
            VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
                    "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));

    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:28,代码来源:SequentialStorageBalancerTest.java


示例11: testPseudonymizationSettings

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
private static void testPseudonymizationSettings(final XMLConfiguration config) throws ConfigurationException, IllegalArgumentException, ClassNotFoundException {
    List<HierarchicalConfiguration<ImmutableNode>> fields = config.configurationsAt("fields.field");
    for (HierarchicalConfiguration field : fields) {
        // Test the name of the field.
        final String constraint = field.getString("constraint");
        final String fieldName = field.getString("name");
        final String algorithmName = field.getString("algorithm.name");
        if ( (fieldName == null) || (constraint == null) || (algorithmName == null) )
            throw new NoSuchElementException("Name of the field, constraint and algoritm needs to be set for each field.");
        // Test the constraint.
        if (!Constraints.CONSTRAINT_MAP.containsKey(field.getString("constraint"))) {
            throw new ConfigurationException(field.getString("constraint") + "should be defined in constraints list (Constraints.java)");
        }
        // TODO PEF-78: Test if the fieldName matches with the context.
        // TODO PEF-79: No expression support.
        // Test if the algorithm is part of the configured algorithms.
        List<HierarchicalConfiguration> parameters = field.childConfigurationsAt("algorithm.params");
        List<AlgorithmParameter> parameterList = new ArrayList<>();

        //TODO PEF-81: Create here a specific parameter type.
        for (HierarchicalConfiguration parameter : parameters) {
            parameterList.add(new AlgorithmParameter(parameter.getString("name"), parameter.getString("value"), Class.forName(parameter.getString("type"))));
        }
        final StringBuilder buffer = new StringBuilder();
        if (!testParseValueTransformerConfiguration(TransformerId.valueOf(algorithmName), parameterList, buffer)) {
            throw new ConfigurationException("Error in configuration for algorithm "+ algorithmName + " " + buffer.toString());
        }
    }
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:30,代码来源:LiveCapture.java


示例12: loadConfiguration

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的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: getConfiguration

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
protected Configuration getConfiguration() {
    try {
        return ((XMLConfiguration) configuration).configurationAt(transformerType.getInternalName() + "." + internalName, true);
    } catch (RuntimeException ex) {
        configuration.setProperty(transformerType.getInternalName() + "." + internalName + ".configured", true);
        return getConfiguration();
    }
}
 
开发者ID:helios-decompiler,项目名称:standalone-app,代码行数:9,代码来源:BaseTransformerController.java


示例14: readExtensionNames

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


示例15: testBalancerStorageSequentialMultiple

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testBalancerStorageSequentialMultiple() throws Exception {

    SequentialHostBalancer balancer = new SequentialHostBalancer();

    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@hosts]", "elm3,elm2,elm1,elm4");
    balancer.setConfiguration(xmlConfiguration);

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    VMwareHost elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm1", "128", "1")));
    elm.setEnabled(true);

    elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm2", "128", "1")));
    elm.setEnabled(true);

    elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm3", "128", "1")));
    elm.setEnabled(false);

    elm = inventory.addHostSystem((VMwareDatacenterInventoryTest
            .createHostSystemProperties("elm4", "128", "1")));
    elm.setEnabled(true);

    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:42,代码来源:SequentialHostBalancerTest.java


示例16: testMultiple

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testMultiple() throws Exception {

    SequentialStorageBalancer balancer = new SequentialStorageBalancer();

    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@storage]", "elm1,elm2,elm3,elm4");
    balancer.setConfiguration(xmlConfiguration);

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    // elm1 does not provide enough resources with respect to configured
    // limit
    VMwareStorage elm = inventory.addStorage("host",
            VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
                    "100", "40"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("50%"));

    elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
            .createDataStoreProperties("elm2", "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));

    elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
            .createDataStoreProperties("elm3", "100", "100"));
    elm.setEnabled(false);
    elm.setLimit(VMwareValue.parse("90%"));

    elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
            .createDataStoreProperties("elm4", "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));

    balancer.setInventory(inventory);

    // getting elm2 since elm1 is not applicable
    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm2", elm.getName());

}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:51,代码来源:SequentialStorageBalancerTest.java


示例17: testMultipleReduce

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Test
public void testMultipleReduce() throws Exception {

    SequentialStorageBalancer balancer = new SequentialStorageBalancer();

    String balancerConfig = "<host><balancer storage=\"elm1,elm2,elm3\" /></host>";
    XMLConfiguration xmlConfiguration = new XMLConfiguration();
    xmlConfiguration.addProperty("[@storage]", "elm1,elm2,elm3");
    balancer.setConfiguration(xmlConfiguration);

    VMwareDatacenterInventory inventory = new VMwareDatacenterInventory();

    VMwareStorage elm = inventory.addStorage("host",
            VMwareDatacenterInventoryTest.createDataStoreProperties("elm1",
                    "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));

    elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
            .createDataStoreProperties("elm2", "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));

    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm1", elm.getName());

    // Now shorten list, so "elm2" is not longer next element
    inventory = new VMwareDatacenterInventory();

    elm = inventory.addStorage("host", VMwareDatacenterInventoryTest
            .createDataStoreProperties("elm3", "100", "100"));
    elm.setEnabled(true);
    elm.setLimit(VMwareValue.parse("90%"));
    balancer.setInventory(inventory);

    elm = balancer.next(properties);
    assertNotNull(elm);
    assertEquals("elm3", elm.getName());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:43,代码来源:SequentialStorageBalancerTest.java


示例18: create

import org.apache.commons.configuration2.XMLConfiguration; //导入依赖的package包/类
@Override
protected XMLConfiguration create(final Map<String, Object> properties) throws ConfigurationException {
    final XMLConfiguration configuration = new XMLConfiguration();
    configuration.initFileLocator(FileLocatorUtils.fileLocator().create());
    return configuration;
}
 
开发者ID:Virtlink,项目名称:commons-configuration2-jackson,代码行数:7,代码来源:BuiltInXmlConfigurationTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FTPConnectMode类代码示例发布时间:2022-05-22
下一篇:
Java ConfigRetrieverOptions类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap