simplifications.
authorErik Brakkee <erik@brakkee.org>
Mon, 8 Aug 2011 21:08:59 +0000 (23:08 +0200)
committerErik Brakkee <erik@brakkee.org>
Mon, 8 Aug 2011 21:08:59 +0000 (23:08 +0200)
config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
impl/src/test/java/org/wamblee/xmlrouter/impl/CompositeConfigTest.java
impl/src/test/java/org/wamblee/xmlrouter/impl/SingleRouterConfigTest.java

index 60eaa617584f925dfa8641607289df1a9388f6b0..9656441ace1bf5ef555871fedcf0e52fb812f971 100644 (file)
@@ -25,9 +25,6 @@ import org.wamblee.xmlrouter.common.Id;
  */
 public interface RouterConfigService {
 
-    // TODO must deal with conflicts with ids provided by applications and those
-    // used by the xmlrouter internally.
-
     /**
      * @return New empty configuration.
      */
index d837f1776aec4039cfe587874a05a0cece8d4694..c9e250e49824fa44272aa3f1addd919f74871c09 100644 (file)
@@ -37,23 +37,21 @@ import org.wamblee.xmlrouter.config.Identifiable;
 public class CompositeConfig<T extends Identifiable<T>> implements
     ExtendedConfig<T> {
 
+    private static final Id<Config> ID = new Id<Config>("compositeconfig");
     private static final String READ_ONLY_INSTANCE = "read only instance";
     private Set<Id<Config>> ids;
-    private Id<Config> id;
     private List<Id<T>> valueIds;
     private List<T> values;
 
-    public CompositeConfig(Id<Config> aId) {
-        notNull("aId", aId);
+    public CompositeConfig() {
         ids = new HashSet<Id<Config>>();
-        id = aId;
         valueIds = new ArrayList<Id<T>>();
         values = new ArrayList<T>();
     }
 
     @Override
     public Id<Config> getId() {
-        return id;
+        return ID;
     }
 
     public void addConfig(Config<T> aConfig) {
index 08a95dececa394295164503153eca2c3606264a7..eabbf3e4e45debbe88782c0072b40de4d83fdcad 100644 (file)
@@ -24,22 +24,19 @@ import org.wamblee.xmlrouter.config.Filter;
 import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
-// TODO test this class.
 public class CompositeRouterConfig implements ExtendedRouterConfig {
 
-    private Id<RouterConfig> id;
+    private static final Id<RouterConfig> ID = new Id<RouterConfig>(
+        "compositerouterconfig");
     private CompositeConfig<DocumentType> documentTypes;
     private CompositeConfig<Transformation> transformations;
     private CompositeConfig<Filter> filters;
 
     public CompositeRouterConfig(Id<RouterConfig> aId,
         Collection<RouterConfig> aConfigs) {
-        id = aId;
-        documentTypes = new CompositeConfig<DocumentType>(new Id<Config>(
-            "documentTypes"));
-        transformations = new CompositeConfig<Transformation>(new Id<Config>(
-            "transformations"));
-        filters = new CompositeConfig<Filter>(new Id<Config>("filters"));
+        documentTypes = new CompositeConfig<DocumentType>();
+        transformations = new CompositeConfig<Transformation>();
+        filters = new CompositeConfig<Filter>();
         for (RouterConfig config : aConfigs) {
             documentTypes.addConfig(config.documentTypeConfig());
             transformations.addConfig(config.transformationConfig());
@@ -47,11 +44,9 @@ public class CompositeRouterConfig implements ExtendedRouterConfig {
         }
     }
 
-    // TODO test id.
-
     @Override
     public Id<RouterConfig> getId() {
-        return id;
+        return ID;
     }
 
     @Override
index 75b8222c04363038f3ed289eb5386a9c7843aded..980bd07601277b1c52b1580df5e44a8a2a7f135c 100644 (file)
@@ -33,8 +33,6 @@ import org.wamblee.xmlrouter.config.Identifiable;
  * 
  * @param <T>
  */
-// TODO make sure that each item inside this config is prefixed with the id of
-// the config.
 public abstract class ConfigImpl<T extends Identifiable<T>> implements
     ExtendedConfig<T> {
 
index f0bf090d2fa1b9f49afe7352e5ce7f77e5db0ef0..40cbcc5116234491680c7a9428f0d3e5201c7017 100644 (file)
@@ -69,7 +69,6 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         };
     }
 
-    // TODO test getId.
     @Override
     public Id<RouterConfig> getId() {
         return id;
index cd1997299d5e631f055fbda2060e0a56f9000c99..ff8c6de09ad0ef312229b0af0e9b14f0aaa285e0 100644 (file)
@@ -26,9 +26,6 @@ import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.RouterConfigService;
 import org.wamblee.xmlrouter.config.Transformation;
 
-// TODO pass unique id of config service in the constructor to allow multiple instances with
-// unique ids (ServiceFactory) 
-
 /**
  * Router configuration service providing an atomic configuration API for the
  * XML router.
index 1f17b68e7c85ce81717305a01844910bc7525d96..9905046d9463998e38f5cb5c4e92cf487b4a3a6a 100644 (file)
@@ -60,24 +60,23 @@ public class CompositeConfigTest {
 
     @Test
     public void testEmptyConfig() {
-        Config<IntClass> composite = composite("c");
-        assertEquals(id("c"), composite.getId());
+        Config<IntClass> composite = composite();
         assertTrue(composite.values().isEmpty());
     }
 
     @Test(expected = RuntimeException.class)
     public void testAddNotAllowed() {
-        composite("c").add(new IntClass(10));
+        composite().add(new IntClass(10));
     }
 
     @Test(expected = RuntimeException.class)
     public void testRemoveNotAllowed() {
-        composite("c").remove(new Id<IntClass>("xxx"));
+        composite().remove(new Id<IntClass>("xxx"));
     }
 
     @Test
     public void testAddConfig() {
-        CompositeConfig<IntClass> composite = composite("c");
+        CompositeConfig<IntClass> composite = composite();
         Config<IntClass> c1 = new ConfigImpl(id("c1")) {
             @Override
             public Identifiable wrap(String aPrefix, Identifiable aT) {
@@ -118,7 +117,7 @@ public class CompositeConfigTest {
 
     @Test(expected = ConfigException.class)
     public void testDuplicatesNotAllowed() {
-        CompositeConfig<IntClass> composite = composite("c");
+        CompositeConfig<IntClass> composite = composite();
         Config<IntClass> c1 = new ConfigImpl(id("c1")) {
             @Override
             public Identifiable wrap(String aPrefix, Identifiable aT) {
@@ -137,7 +136,7 @@ public class CompositeConfigTest {
 
     @Test
     public void testDuplicateItem() {
-        CompositeConfig<IntClass> composite = composite("c");
+        CompositeConfig<IntClass> composite = composite();
         Config<IntClass> c1 = new ConfigImpl(id("c1")) {
             @Override
             public Identifiable wrap(String aPrefix, Identifiable aT) {
@@ -166,8 +165,8 @@ public class CompositeConfigTest {
         assertTrue(composite.values().contains(i1));
     }
 
-    private CompositeConfig<IntClass> composite(String aId) {
-        return new CompositeConfig<IntClass>(id(aId));
+    private CompositeConfig<IntClass> composite() {
+        return new CompositeConfig<IntClass>();
     }
 
     private Id<Config> id(String aId) {
index a344f7201b34bd48a88e37ef2078ffd7db9c5f89..6ec16b1b8d5857f7c7eaf9f48eb1a02a0422e586 100644 (file)
@@ -33,6 +33,7 @@ public class SingleRouterConfigTest {
     @Before
     public void setUp() {
         config = new SingleRouterConfig(new Id<RouterConfig>("routerconfig"));
+        assertEquals("routerconfig", config.getId().getId());
     }
 
     @Test