simplifications.
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
index c58ef8909f6e6db8ebc19bcdda4fea35b3ece394..40cbcc5116234491680c7a9428f0d3e5201c7017 100644 (file)
  */
 package org.wamblee.xmlrouter.impl;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 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 equality based on ids for the single routerconfig. 
+// TODO implement copying of routerconfig. 
+
 /**
  * Represents a single configuration set of a single configuration client of the
  * XML router.
@@ -30,7 +32,7 @@ import org.wamblee.xmlrouter.config.Transformation;
  * @author Erik Brakkee
  */
 public class SingleRouterConfig implements ExtendedRouterConfig {
-    private AtomicLong sequenceNumbers;
+    private Id<RouterConfig> id;
     private ExtendedConfig<DocumentType> documentTypes;
     private ExtendedConfig<Transformation> transformations;
     private ExtendedConfig<Filter> filters;
@@ -38,32 +40,40 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
     /**
      * Constructs a router configuration.
      * 
-     * @param aSequenceNumberGenerator
-     *            Sequence number generator to use.
+     * @param aId
+     *            Unique id for this configuration.
      */
-    public SingleRouterConfig(AtomicLong aSequenceNumberGenerator) {
-        sequenceNumbers = aSequenceNumberGenerator;
-        documentTypes = new ConfigImpl<DocumentType>(sequenceNumbers) {
+    public SingleRouterConfig(Id<RouterConfig> aId) {
+        id = aId;
+        documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
+            aId.getId() + ".documenttypes")) {
             @Override
-            public DocumentType wrap(Id<DocumentType> aId, DocumentType aT) {
-                return new RobustDocumentType(aId, aT);
+            public DocumentType wrap(String aPrefix, DocumentType aT) {
+                return new RobustDocumentType(aPrefix, aT);
             }
         };
-        transformations = new ConfigImpl<Transformation>(sequenceNumbers) {
+        transformations = new ConfigImpl<Transformation>(new Id<Config>(
+            aId.getId() + ".transformations")) {
             @Override
-            public Transformation wrap(Id<Transformation> aId,
+            public Transformation wrap(String aPrefix,
                 Transformation aTransformation) {
-                return new RobustTransformation(aId, aTransformation);
+                return new RobustTransformation(aPrefix, aTransformation);
             }
         };
-        filters = new ConfigImpl<Filter>(sequenceNumbers) {
+        filters = new ConfigImpl<Filter>(new Id<Config>(aId.getId() +
+            ".filters")) {
             @Override
-            public Filter wrap(Id<Filter> aId, Filter aFilter) {
-                return new RobustFilter(aId, aFilter);
+            public Filter wrap(String aPrefix, Filter aFilter) {
+                return new RobustFilter(aPrefix, aFilter);
             }
         };
     }
 
+    @Override
+    public Id<RouterConfig> getId() {
+        return id;
+    }
+
     @Override
     public Config<DocumentType> documentTypeConfig() {
         return documentTypes;