Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.CompositeConfiguration


    "whirr-hadoop-default.properties";

  private static Configuration build(ClusterSpec clusterSpec, Cluster cluster,
      Configuration defaults, String prefix)
      throws ConfigurationException {
    CompositeConfiguration config = new CompositeConfiguration();
    config.setDelimiterParsingDisabled(true);
    Configuration sub = clusterSpec.getConfigurationForKeysWithPrefix(prefix);
    config.addConfiguration(sub.subset(prefix)); // remove prefix
    config.addConfiguration(defaults.subset(prefix));
    return config;
  }
View Full Code Here


    return config.getList(key.getConfigName());
  }
 
  private Configuration composeWithDefaults(Configuration userConfig)
      throws ConfigurationException {
    CompositeConfiguration composed = new CompositeConfiguration();
    composed.addConfiguration(userConfig);
    composed.addConfiguration(new PropertiesConfiguration(
        getClass().getClassLoader().getResource(DEFAULT_PROPERTIES)));
    return composed;
  }
View Full Code Here

        i = getListValue("exchanges.exchange.name").iterator();
        int count = 0;
        while (i.hasNext())
        {
            CompositeConfiguration mungedConf = new CompositeConfiguration();
            mungedConf.addConfiguration(config.subset("exchanges.exchange(" + count++ + ")"));
            mungedConf.addConfiguration(_configuration.subset("exchanges"));
            String exchName = (String) i.next();
            _exchanges.put(exchName, new ExchangeConfiguration(exchName, mungedConf));
        }
    }
View Full Code Here

        newQueueConfig.setProperty("name", queue.getName());

        try
        {
            //Set the queue name
            CompositeConfiguration mungedConf = new CompositeConfiguration();
            //Set the queue name
            mungedConf.addConfiguration(newQueueConfig);
            //Set the global queue configuration
            mungedConf.addConfiguration(getConfig().subset("queues"));

            // Set configuration
            queueConfig.setConfiguration("virtualhosts.virtualhost.queues", mungedConf);
        }
        catch (ConfigurationException e)
View Full Code Here

   * set to 1 second to prevent excessive date stamp checking.
   */
  private void loadConfiguration() throws ConfigurationException
  {
    //Properties from system properties
    CompositeConfiguration compositeConfig = new CompositeConfiguration();
    compositeConfig.addConfiguration(new SystemConfiguration());
    //Properties from file
    PropertiesConfiguration propConfig = null;
          final String filename = System.getProperty("juddi.propertiesFile");
    if (filename != null)
          {
      propConfig = new PropertiesConfiguration(filename);
    } else {
      propConfig = new PropertiesConfiguration(JUDDI_PROPERTIES);
    }
    URL url = ClassUtil.getResource(JUDDI_PROPERTIES, this.getClass());
    log.info("Reading from properties file:  " + url);
    long refreshDelay = propConfig.getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY, 1000l);
    log.debug("Setting refreshDelay to " + refreshDelay);
    FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy();
    fileChangedReloadingStrategy.setRefreshDelay(refreshDelay);
    propConfig.setReloadingStrategy(fileChangedReloadingStrategy);
    compositeConfig.addConfiguration(propConfig);
   
   
    Properties properties = new Properties();
    if ("Hibernate".equals(propConfig.getString(Property.PERSISTENCE_PROVIDER))) {
      if (propConfig.containsKey(Property.DATASOURCE))
        properties.put("hibernate.connection.datasource",propConfig.getString(Property.DATASOURCE));
      if (propConfig.containsKey(Property.HBM_DDL_AUTO))
        properties.put("hibernate.hbm2ddl.auto",propConfig.getString(Property.HBM_DDL_AUTO));
      if (propConfig.containsKey(Property.DEFAULT_SCHEMA))
        properties.put("hibernate.default_schema",propConfig.getString(Property.DEFAULT_SCHEMA));
      if (propConfig.containsKey(Property.HIBERNATE_DIALECT))
        properties.put("hibernate.dialect",propConfig.getString(Property.HIBERNATE_DIALECT));
    }
    // initialize the entityManagerFactory.
    PersistenceManager.initializeEntityManagerFactory(propConfig.getString(Property.JUDDI_PERSISTENCEUNIT_NAME), properties);
    // Properties from the persistence layer
    MapConfiguration persistentConfig = new MapConfiguration(getPersistentConfiguration(compositeConfig));
   
    compositeConfig.addConfiguration(persistentConfig);
    //Making the new configuration globally accessible.
    config = compositeConfig;
  }
View Full Code Here

    new InstanceTemplate(1, "a b");
  }

  @Test
  public void testApplyRoleAliases() {
    CompositeConfiguration c = new CompositeConfiguration();
    Configuration config = new PropertiesConfiguration();
    config.addProperty("whirr.instance-templates", "1 nn+jt+tt+dn+zk");
    c.addConfiguration(config);   
    InstanceTemplate template = InstanceTemplate.parse(c).get(0);
    Set<String> expected = Sets.newLinkedHashSet(Arrays.asList(new String[]{
        "hadoop-namenode", "hadoop-jobtracker", "hadoop-tasktracker",
        "hadoop-datanode", "zookeeper"}));
    assertThat(template.getRoles(), is(expected));
View Full Code Here

    }
  }
 
  @Test
  public void testApplySubroleAliases() {
    CompositeConfiguration c = new CompositeConfiguration();
    Configuration config = new PropertiesConfiguration();
    config.addProperty("whirr.instance-templates",
        "1 puppet:somepup::pet+something-else, 1 something-else-only");
    c.addConfiguration(config);   
    InstanceTemplate template = InstanceTemplate.parse(c).get(0);
    Set<String> expected = Sets.newLinkedHashSet(Arrays.asList(new String[]{
        "puppet:somepup::pet", "something-else"}));
    assertThat(template.getRoles(), is(expected));
   
View Full Code Here

  private Cluster cluster;

  @Before
  public void setUp() throws ConfigurationException, IOException,
      JSchException {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration("whirr-cassandra-test.properties"));
    clusterSpec = new ClusterSpec(config);
    if (clusterSpec.getPrivateKey() == null) {
      Map<String, String> pair = KeyPair.generate();
      clusterSpec.setPublicKey(pair.get("public"));
      clusterSpec.setPrivateKey(pair.get("private"));
View Full Code Here

  private HadoopCluster cluster;
 
  @Before
  public void setUp() throws ConfigurationException, IOException,
      JSchException {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration("whirr-hadoop-test.properties"));
    clusterSpec = new ClusterSpec(config);
    if (clusterSpec.getPrivateKey() == null) {
      Map<String, String> pair = KeyPair.generate();
      clusterSpec.setPublicKey(pair.get("public"));
      clusterSpec.setPrivateKey(pair.get("private"));
View Full Code Here

        }
        else
        {
            _default = AuthzResult.DENIED;
        }
        CompositeConfiguration finalConfig = new CompositeConfiguration(config);
       
        List subFiles = config.getList("xml[@fileName]");
        for (Object subFile : subFiles)
        {
            finalConfig.addConfiguration(new XMLConfiguration((String) subFile));
        }

        // all rules must have an access attribute
        int numRules = finalConfig.getList("rule[@access]").size();
        _rules = new FirewallRule[numRules];
        for (int i = 0; i < numRules; i++)
        {
            FirewallRule rule = new FirewallRule(finalConfig.getString("rule(" + i + ")[@access]"), finalConfig.getList("rule("
                    + i + ")[@network]"), finalConfig.getList("rule(" + i + ")[@hostname]"));
            _rules[i] = rule;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.CompositeConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.