Skip to content

Commit

Permalink
fixed combined config
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Oct 28, 2015
1 parent 5e5f4f0 commit 689745f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.g3force</groupId>
<artifactId>configurable</artifactId>
<version>v1.2</version>
<version>v1.3</version>
<name>configurable</name>

<properties>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>com.github.g3force</groupId>
<artifactId>String2ValueConverter</artifactId>
<version>v1.4</version>
<version>v1.5</version>
</dependency>

<dependency>
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/com/github/g3force/configurable/AConfigClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import org.apache.commons.configuration.CombinedConfiguration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.NodeCombiner;
import org.apache.commons.configuration.tree.UnionCombiner;
import org.apache.log4j.Logger;


Expand Down Expand Up @@ -53,6 +50,7 @@ public AConfigClient(final String name, final String path)
super();
this.name = name;
this.path = path;
loadFileConfig();
}


Expand Down Expand Up @@ -82,17 +80,20 @@ public HierarchicalConfiguration getFileConfig()
@Override
public HierarchicalConfiguration getCombinedConfig()
{
// Create and initialize the node combiner
NodeCombiner combiner = new UnionCombiner();
combiner.addListNode("table"); // mark table as list node
// this is needed only if there are ambiguities

// Construct the combined configuration
CombinedConfiguration cc = new CombinedConfiguration(combiner);
cc.addConfiguration(getLocalConfig());
cc.addConfiguration(getFileConfig());
HierarchicalConfiguration cfg = new HierarchicalConfiguration(getLocalConfig());
ConfigAnnotationProcessor.merge(cfg, getFileConfig());
return cfg;

return cc;
// does not work:
// // Create and initialize the node combiner
// NodeCombiner combiner = new OverrideCombiner();
//
// // Construct the combined configuration
// CombinedConfiguration cc = new CombinedConfiguration(combiner);
// cc.addConfiguration(getFileConfig());
// cc.addConfiguration(getLocalConfig());
//
// return cc;
}


Expand Down

0 comments on commit 689745f

Please sign in to comment.