Config no longer implements Identifiable because this was in violation of the contrac...
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
index 4ecaad4a35d633679620f791426242f868784b35..195f72da66295517bce3aec611c3fe05f3fd0cc8 100644 (file)
 package org.wamblee.xmlrouter.impl;
 
 import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
 import org.wamblee.xmlrouter.config.DocumentType;
 import org.wamblee.xmlrouter.config.Filter;
-import org.wamblee.xmlrouter.config.RouterConfig;
 import org.wamblee.xmlrouter.config.Transformation;
 
-// TODO implement copying of routerconfig. 
-
 /**
  * Represents a single configuration set of a single configuration client of the
  * XML router.
@@ -33,7 +29,7 @@ import org.wamblee.xmlrouter.config.Transformation;
 public class SingleRouterConfig implements ExtendedRouterConfig {
 
     public static final class DocumentConfig extends ConfigImpl<DocumentType> {
-        public DocumentConfig(Id<Config> aId) {
+        public DocumentConfig(String aId) {
             super(DocumentType.class, aId);
         }
 
@@ -42,14 +38,14 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public DocumentType wrap(String aPrefix, DocumentType aT) {
-            return new RobustDocumentType("", aT);
+        public DocumentType wrap(DocumentType aT) {
+            return new RobustDocumentType(aT);
         }
     }
 
     public static final class TransformationConfig extends
         ConfigImpl<Transformation> {
-        public TransformationConfig(Id<Config> aId) {
+        public TransformationConfig(String aId) {
             super(Transformation.class, aId);
         }
 
@@ -58,14 +54,13 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public Transformation wrap(String aPrefix,
-            Transformation aTransformation) {
-            return new RobustTransformation("", aTransformation);
+        public Transformation wrap(Transformation aTransformation) {
+            return new RobustTransformation(aTransformation);
         }
     }
 
     public static final class FilterConfig extends ConfigImpl<Filter> {
-        public FilterConfig(Id<Config> aId) {
+        public FilterConfig(String aId) {
             super(Filter.class, aId);
         }
 
@@ -74,12 +69,12 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
         }
 
         @Override
-        public Filter wrap(String aPrefix, Filter aFilter) {
+        public Filter wrap(Filter aFilter) {
             return new RobustFilter("", aFilter);
         }
     }
 
-    private Id<RouterConfig> id;
+    private String prefix;
 
     private DocumentConfig documentTypes;
     private TransformationConfig transformations;
@@ -88,20 +83,18 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
     /**
      * Constructs a router configuration.
      * 
-     * @param aId
+     * @param aPrefix
      *            Unique id for this configuration.
      */
-    public SingleRouterConfig(Id<RouterConfig> aId) {
-        id = aId;
-        documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
-            ".documenttypes"));
-        transformations = new TransformationConfig(new Id<Config>(aId.getId() +
-            ".transformations"));
-        filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
+    public SingleRouterConfig(String aPrefix) {
+        prefix = aPrefix;
+        documentTypes = new DocumentConfig(aPrefix + ".documenttypes");
+        transformations = new TransformationConfig(aPrefix + ".transformations");
+        filters = new FilterConfig(aPrefix + ".filters");
     }
 
     public SingleRouterConfig(SingleRouterConfig aConfig) {
-        id = aConfig.id;
+        prefix = aConfig.prefix;
         documentTypes = new DocumentConfig(aConfig.documentTypes);
         transformations = new TransformationConfig(aConfig.transformations);
         filters = new FilterConfig(aConfig.filters);
@@ -109,7 +102,11 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
 
     @Override
     public Id<RouterConfig> getId() {
-        return id;
+        return new Id<RouterConfig>(prefix);
+    }
+
+    public String getPrefix() {
+        return prefix;
     }
 
     @Override