X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FSingleRouterConfig.java;h=8eab34b708996198b73c4cbfd271462937ff1119;hb=537cfb1a832b99e2c0a55b4634cd2a42f7fbcc09;hp=c58ef8909f6e6db8ebc19bcdda4fea35b3ece394;hpb=f70baadfd579f4d3aa2e8c9ee7d758fb37d7872f;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java index c58ef89..8eab34b 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java @@ -15,14 +15,15 @@ */ 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 copying of routerconfig. + /** * Represents a single configuration set of a single configuration client of the * XML router. @@ -30,7 +31,8 @@ import org.wamblee.xmlrouter.config.Transformation; * @author Erik Brakkee */ public class SingleRouterConfig implements ExtendedRouterConfig { - private AtomicLong sequenceNumbers; + private Id id; + private ExtendedConfig documentTypes; private ExtendedConfig transformations; private ExtendedConfig 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(sequenceNumbers) { + public SingleRouterConfig(Id aId) { + id = aId; + documentTypes = new ConfigImpl(new Id( + aId.getId() + ".documenttypes")) { @Override - public DocumentType wrap(Id aId, DocumentType aT) { - return new RobustDocumentType(aId, aT); + public DocumentType wrap(String aPrefix, DocumentType aT) { + return new RobustDocumentType(aPrefix, aT); } }; - transformations = new ConfigImpl(sequenceNumbers) { + transformations = new ConfigImpl(new Id( + aId.getId() + ".transformations")) { @Override - public Transformation wrap(Id aId, + public Transformation wrap(String aPrefix, Transformation aTransformation) { - return new RobustTransformation(aId, aTransformation); + return new RobustTransformation(aPrefix, aTransformation); } }; - filters = new ConfigImpl(sequenceNumbers) { + filters = new ConfigImpl(new Id(aId.getId() + + ".filters")) { @Override - public Filter wrap(Id aId, Filter aFilter) { - return new RobustFilter(aId, aFilter); + public Filter wrap(String aPrefix, Filter aFilter) { + return new RobustFilter(aPrefix, aFilter); } }; } + @Override + public Id getId() { + return id; + } + @Override public Config documentTypeConfig() { return documentTypes; @@ -78,4 +88,25 @@ public class SingleRouterConfig implements ExtendedRouterConfig { public Config filterConfig() { return filters; } + + @Override + public boolean equals(Object aObj) { + if (aObj == null) { + return false; + } + if (!(aObj instanceof SingleRouterConfig)) { + return false; + } + SingleRouterConfig obj = (SingleRouterConfig) aObj; + + return documentTypes.equals(obj.documentTypes) && + transformations.equals(obj.transformations) && + filters.equals(obj.filters); + } + + @Override + public int hashCode() { + return documentTypes.hashCode() + transformations.hashCode() + + filters.hashCode(); + } }