List of usage examples for org.apache.commons.configuration CombinedConfiguration addConfiguration
public void addConfiguration(AbstractConfiguration config, String name, String at)
From source file:edu.cwru.sepia.Main.java
private static Runner getRunner(HierarchicalConfiguration globalConfig, StateCreator stateCreator, Agent[] agents) throws ClassNotFoundException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Class<?> runnerClass = Class.forName(globalConfig.getString("runner.ClassName")); CombinedConfiguration config = new CombinedConfiguration(); config.addConfiguration(globalConfig.configurationAt("model"), "model", "model"); config.addConfiguration(globalConfig.configurationAt("runner.properties"), "runner.properties", "runner.properties"); return (edu.cwru.sepia.runner.Runner) runnerClass .getConstructor(Configuration.class, StateCreator.class, Agent[].class) .newInstance(config, stateCreator, agents); }
From source file:com.shanke.common.conf.CustomConfigurationBuilder.java
/** * Initializes a combined configuration for the configurations of a specific * section. This method is called for the override and for the additional * section (if it exists)./*from w w w. jav a2 s . c o m*/ * * @param config * the configuration to be initialized * @param containedConfigs * the list with the declaratinos of the contained configurations * @param keyListNodes * a list with the declaration of list nodes * @throws ConfigurationException * if an error occurs */ protected void initCombinedConfiguration(CombinedConfiguration config, List containedConfigs, String keyListNodes) throws ConfigurationException { List listNodes = getList(keyListNodes); for (Iterator it = listNodes.iterator(); it.hasNext();) { config.getNodeCombiner().addListNode((String) it.next()); } for (Iterator it = containedConfigs.iterator(); it.hasNext();) { HierarchicalConfiguration conf = (HierarchicalConfiguration) it.next(); ConfigurationDeclaration decl = new ConfigurationDeclaration(this, conf); AbstractConfiguration newConf = createConfigurationAt(decl); if (newConf != null) { config.addConfiguration(newConf, decl.getConfiguration().getString(ATTR_NAME), decl.getAt()); } } }
From source file:org.ssh.test.conf.IConfiguration.java
/** * Returns a copy of this object. This implementation performs a deep clone, * i.e. all contained configurations will be cloned, too. For this to work, * all contained configurations must be cloneable. Registered event * listeners won't be cloned. The clone will use the same node combiner than * the original.//from www. j av a 2 s . c om * * @return the copied object */ @Override public Object clone() { CombinedConfiguration copy = (CombinedConfiguration) super.clone(); copy.clear(); for (ConfigData cd : configurations) { copy.addConfiguration( (AbstractConfiguration) ConfigurationUtils.cloneConfiguration(cd.getConfiguration()), cd.getName(), cd.getAt()); } copy.setRootNode(new DefaultConfigurationNode()); return copy; }