*/
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.
* @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;
* @param aSequenceNumberGenerator
* Sequence number generator to use.
*/
- 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>(
+ "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>(
+ "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>("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);
}
};
}
+ // TODO test getId.
+ @Override
+ public Id<RouterConfig> getId() {
+ return id;
+ }
+
@Override
public Config<DocumentType> documentTypeConfig() {
return documentTypes;
public Config<Filter> filterConfig() {
return filters;
}
-
- @Override
- public boolean isDirty() {
- return documentTypes.isDirty() || transformations.isDirty() ||
- filters.isDirty();
- }
-
- @Override
- public void resetDirty() {
- documentTypes.resetDirty();
- filters.resetDirty();
- transformations.resetDirty();
- }
-
}