git://wamblee.org
/
xmlrouter
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e523856
)
now making sure that ids re prefixed by the config id.
author
Erik Brakkee
<erik@brakkee.org>
Mon, 1 Aug 2011 20:44:41 +0000
(22:44 +0200)
committer
Erik Brakkee
<erik@brakkee.org>
Mon, 1 Aug 2011 20:44:41 +0000
(22:44 +0200)
15 files changed:
common/src/main/java/org/wamblee/xmlrouter/common/Id.java
patch
|
blob
|
history
config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
patch
|
blob
|
history
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
patch
|
blob
|
history
impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
patch
|
blob
|
history
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
patch
|
blob
|
history
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustFilterTest.java
patch
|
blob
|
history
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java
patch
|
blob
|
history
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
patch
|
blob
|
history
diff --git
a/common/src/main/java/org/wamblee/xmlrouter/common/Id.java
b/common/src/main/java/org/wamblee/xmlrouter/common/Id.java
index 1d31c8bab25115da24949ae4383326681a17f3d2..a50b8f2c7b3dcd8999b641df7b60c9a4fe5a981d 100644
(file)
--- a/
common/src/main/java/org/wamblee/xmlrouter/common/Id.java
+++ b/
common/src/main/java/org/wamblee/xmlrouter/common/Id.java
@@
-62,7
+62,7
@@
public class Id<T> implements Comparable<Id<T>> {
if (!(aObj instanceof Id)) {
return false;
}
if (!(aObj instanceof Id)) {
return false;
}
- return id
== ((Id<T>) aObj).id
;
+ return id
.equals(((Id<T>) aObj).id)
;
}
@Override
}
@Override
diff --git
a/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
b/config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
index 5fc7f2ed827373966cf6cc29cdea8cd5df4b9e2f..60eaa617584f925dfa8641607289df1a9388f6b0 100644
(file)
--- a/
config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
+++ b/
config/src/main/java/org/wamblee/xmlrouter/config/RouterConfigService.java
@@
-25,10
+25,13
@@
import org.wamblee.xmlrouter.common.Id;
*/
public interface RouterConfigService {
*/
public interface RouterConfigService {
+ // TODO must deal with conflicts with ids provided by applications and those
+ // used by the xmlrouter internally.
+
/**
* @return New empty configuration.
*/
/**
* @return New empty configuration.
*/
- RouterConfig emptyConfig();
+ RouterConfig emptyConfig(
String aId
);
/**
* Applies a given configuration.
/**
* Applies a given configuration.
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
index 5166315e7640504643c80307c42ea782a0902a9c..56e3e8b3f7cb799f77e23d68c42a43b2b1a69864 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/CompositeConfig.java
@@
-21,6
+21,13
@@
import java.util.List;
import org.wamblee.xmlrouter.common.Id;
import org.wamblee.xmlrouter.config.Config;
import org.wamblee.xmlrouter.common.Id;
import org.wamblee.xmlrouter.config.Config;
+/**
+ * Composite config. The composite config
+ *
+ * @author Erik Brakkee
+ *
+ * @param <T>
+ */
public class CompositeConfig<T> implements ExtendedConfig<T> {
private Id<Config> id;
public class CompositeConfig<T> implements ExtendedConfig<T> {
private Id<Config> id;
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
index c561e364b287958a169a90eb611baa58769ed3fc..5beeed5c12da92ece9bb9833d39bbe0c0bc2241e 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/ConfigImpl.java
@@
-31,6
+31,8
@@
import org.wamblee.xmlrouter.config.Identifiable;
*
* @param <T>
*/
*
* @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> implements
ExtendedConfig<T> {
public abstract class ConfigImpl<T extends Identifiable> implements
ExtendedConfig<T> {
@@
-60,7
+62,7
@@
public abstract class ConfigImpl<T extends Identifiable> implements
public synchronized void add(T aT) {
// TODO test duplicate ids.
notNull(aT);
public synchronized void add(T aT) {
// TODO test duplicate ids.
notNull(aT);
- registered.add(wrap(aT));
+ registered.add(wrap(
id.getId() + ".",
aT));
}
/**
}
/**
@@
-70,7
+72,7
@@
public abstract class ConfigImpl<T extends Identifiable> implements
* Object to wrap.
* @return Wrapped object.
*/
* Object to wrap.
* @return Wrapped object.
*/
- public abstract T wrap(T aT);
+ public abstract T wrap(
String aPrefix,
T aT);
/*
* (non-Javadoc)
/*
* (non-Javadoc)
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
index 52244837dda20bcc70de5513c7c87be487a59857..3f26f7b7c761fd57b2677ae9f5cd63f86d68286f 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustDocumentType.java
@@
-45,8
+45,8
@@
public class RobustDocumentType extends RobustIdentifiable<DocumentType>
* @param aType
* Document type to wrap.
*/
* @param aType
* Document type to wrap.
*/
- public RobustDocumentType(DocumentType aType) {
- super(aType);
+ public RobustDocumentType(
String aPrefix,
DocumentType aType) {
+ super(a
Prefix, a
Type);
type = aType;
}
type = aType;
}
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
index 056690a39e00178f96ca07a20ecdf806a22fad56..823c64d77276a2c0ff0abd9a70ad544b33c352be 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustFilter.java
@@
-38,13
+38,15
@@
public class RobustFilter extends RobustIdentifiable<Filter> implements Filter {
/**
* Constructs the wrapper.
*
/**
* Constructs the wrapper.
*
+ * @param aPrefix
+ * prefix to use for ids.
* @param aId
* Id.
* @param aFilter
* Filter to wrap.
*/
* @param aId
* Id.
* @param aFilter
* Filter to wrap.
*/
- public RobustFilter(Filter aFilter) {
- super(aFilter);
+ public RobustFilter(
String aPrefix,
Filter aFilter) {
+ super(a
Prefix, a
Filter);
filter = aFilter;
}
filter = aFilter;
}
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
index f3da5f401e98f0dd7ae252c8c04458c781a51ad9..640e37e13385402e9414c6beb2719bb3d6e2d378 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustIdentifiable.java
@@
-37,15
+37,16
@@
public class RobustIdentifiable<T> implements Identifiable<T> {
// TODO test this class.
// TODO test that id is constant even though delegated changes its id.
// TODO test this class.
// TODO test that id is constant even though delegated changes its id.
- public RobustIdentifiable(Identifiable<T> aIdentifiable) {
+ public RobustIdentifiable(
String aPrefix,
Identifiable<T> aIdentifiable) {
// TODO test id is null
// TODO getId() throws exception
try {
id = aIdentifiable.getId();
if (id == null) {
id = new Id<T>(Constants.UNKNOWN_ID.toString());
// TODO test id is null
// TODO getId() throws exception
try {
id = aIdentifiable.getId();
if (id == null) {
id = new Id<T>(Constants.UNKNOWN_ID.toString());
- throw new RuntimeException(
- "Temporary to catch nulls during refactoring");
+ temporarilyThrowException();
+ } else {
+ id = new Id<T>(aPrefix + id.getId());
}
} catch (Exception e) {
LOGGER
}
} catch (Exception e) {
LOGGER
@@
-54,6
+55,11
@@
public class RobustIdentifiable<T> implements Identifiable<T> {
}
}
+ private void temporarilyThrowException() {
+ throw new RuntimeException(
+ "Temporary to catch nulls during refactoring");
+ }
+
@Override
public Id<T> getId() {
return id;
@Override
public Id<T> getId() {
return id;
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
index 2fa025e005a836410517332d8f7ff2b3053ffbf7..cf0210d3094045b85e5a9c4d36b1b0ce4475bf52 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/RobustTransformation.java
@@
-45,8
+45,8
@@
public class RobustTransformation extends RobustIdentifiable<Transformation>
* @param aTransformation
* Wrapped transformation.
*/
* @param aTransformation
* Wrapped transformation.
*/
- public RobustTransformation(Transformation aTransformation) {
- super(aTransformation);
+ public RobustTransformation(
String aPrefix,
Transformation aTransformation) {
+ super(a
Prefix, a
Transformation);
transformation = aTransformation;
}
transformation = aTransformation;
}
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 5e2fffe4829009b1d67cc26c8f66bc2808b776a7..b069215b102731099ee88f6a22384af64a5ac886 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java
@@
-45,21
+45,22
@@
public class SingleRouterConfig implements ExtendedRouterConfig {
documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
"documentTypes")) {
@Override
documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
"documentTypes")) {
@Override
- public DocumentType wrap(DocumentType aT) {
- return new RobustDocumentType(aT);
+ public DocumentType wrap(
String aPrefix,
DocumentType aT) {
+ return new RobustDocumentType(a
Prefix, a
T);
}
};
transformations = new ConfigImpl<Transformation>(new Id<Config>(
"transformations")) {
@Override
}
};
transformations = new ConfigImpl<Transformation>(new Id<Config>(
"transformations")) {
@Override
- public Transformation wrap(Transformation aTransformation) {
- return new RobustTransformation(aTransformation);
+ public Transformation wrap(String aPrefix,
+ Transformation aTransformation) {
+ return new RobustTransformation(aPrefix, aTransformation);
}
};
filters = new ConfigImpl<Filter>(new Id<Config>("filters")) {
@Override
}
};
filters = new ConfigImpl<Filter>(new Id<Config>("filters")) {
@Override
- public Filter wrap(Filter aFilter) {
- return new RobustFilter(aFilter);
+ public Filter wrap(
String aPrefix,
Filter aFilter) {
+ return new RobustFilter(a
Prefix, a
Filter);
}
};
}
}
};
}
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
index 054956df0a0e6d8255119298fb751e9fd9ed23d7..c60e546bf0f0312019ab57bc35d845592e3806e5 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouterConfigService.java
@@
-15,7
+15,6
@@
*/
package org.wamblee.xmlrouter.impl;
*/
package org.wamblee.xmlrouter.impl;
-import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.wamblee.xmlrouter.common.Id;
import java.util.concurrent.atomic.AtomicLong;
import org.wamblee.xmlrouter.common.Id;
@@
-39,17
+38,16
@@
public class XMLRouterConfigService implements RouterConfigService {
sequence = new AtomicLong(1L);
config = aConfig;
routerConfigs = new ConfigImpl<RouterConfig>(new Id<Config>("config")) {
sequence = new AtomicLong(1L);
config = aConfig;
routerConfigs = new ConfigImpl<RouterConfig>(new Id<Config>("config")) {
- public RouterConfig wrap(RouterConfig aT) {
+ public RouterConfig wrap(
String aPrefix,
RouterConfig aT) {
return aT;
}
};
}
@Override
return aT;
}
};
}
@Override
- public RouterConfig emptyConfig() {
- // TODO check and document API impacts.
- String id = UUID.randomUUID().toString();
- return new SingleRouterConfig(new Id<RouterConfig>(id));
+ public RouterConfig emptyConfig(String aId) {
+ // TODO check AP{ impacts.
+ return new SingleRouterConfig(new Id<RouterConfig>(aId));
}
@Override
}
@Override
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
index 5e3ad92059625e3b4b5e1a5152da4ed0e9feefd1..781a53acab9c3ef7a3e3fc051bc3fe5fff73f14d 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/ConfigImplTest.java
@@
-28,14
+28,18
@@
import org.wamblee.xmlrouter.config.Identifiable;
public class ConfigImplTest {
public class ConfigImplTest {
+ private static final String CONFIG_TYPE = "transformation";
+
private static interface MyType extends Identifiable {
}
private static class MyTypeWrapper implements MyType {
private static interface MyType extends Identifiable {
}
private static class MyTypeWrapper implements MyType {
+ private String prefix;
private MyType type;
private MyType type;
- public MyTypeWrapper(MyType aType) {
+ public MyTypeWrapper(String aPrefix, MyType aType) {
+ prefix = aPrefix;
type = aType;
}
type = aType;
}
@@
-45,7
+49,7
@@
public class ConfigImplTest {
@Override
public Id getId() {
@Override
public Id getId() {
- return
type.getId(
);
+ return
new Id(prefix + type.getId().getId()
);
}
}
}
}
@@
-55,10
+59,10
@@
public class ConfigImplTest {
@Before
public void setUp() {
sequence = new AtomicLong(1L);
@Before
public void setUp() {
sequence = new AtomicLong(1L);
- config = new ConfigImpl<MyType>(new Id<Config>(
"mytype"
)) {
+ config = new ConfigImpl<MyType>(new Id<Config>(
CONFIG_TYPE
)) {
@Override
@Override
- public MyType wrap(MyType aT) {
- return new MyTypeWrapper(aT);
+ public MyType wrap(
String aPrefix,
MyType aT) {
+ return new MyTypeWrapper(a
Prefix, a
T);
}
};
}
}
};
}
@@
-73,6
+77,8
@@
public class ConfigImplTest {
assertEquals(1, config.values().size());
assertTrue(config.values().get(0) instanceof MyTypeWrapper);
assertSame(type1, ((MyTypeWrapper) config.values().get(0)).getType());
assertEquals(1, config.values().size());
assertTrue(config.values().get(0) instanceof MyTypeWrapper);
assertSame(type1, ((MyTypeWrapper) config.values().get(0)).getType());
+ assertEquals(CONFIG_TYPE + "." + type1.getId().getId(), config.values()
+ .get(0).getId().getId());
// add another one.
MyType type2 = mock(MyType.class);
// add another one.
MyType type2 = mock(MyType.class);
@@
-91,7
+97,7
@@
public class ConfigImplTest {
assertEquals(1, config.values().size());
assertEquals(1, config.values().size());
- assertTrue(config.remove(new Id("type1")));
+ assertTrue(config.remove(new Id(
CONFIG_TYPE + "." +
"type1")));
assertTrue(config.values().isEmpty());
}
assertTrue(config.values().isEmpty());
}
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
index 254826cb9573ebc2bc46d87d7562c412220b4714..aa724e26f3d10ca0f46fb3f976ad410ea0a470cf 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustDocumentTypeTest.java
@@
-34,7
+34,7
@@
public class RobustDocumentTypeTest {
@Before
public void setUp() {
documentType = mock(DocumentType.class);
@Before
public void setUp() {
documentType = mock(DocumentType.class);
- robust = new RobustDocumentType(documentType);
+ robust = new RobustDocumentType(
"app1",
documentType);
source = mock(DOMSource.class);
}
source = mock(DOMSource.class);
}
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustFilterTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustFilterTest.java
index 372511236cb0ba8b80c1d3a7385afdc0d2ce9847..4c8218d50c796e82ba7258a15e9586658c58524d 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustFilterTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustFilterTest.java
@@
-34,7
+34,7
@@
public class RobustFilterTest {
@Before
public void setUp() {
filter = mock(Filter.class);
@Before
public void setUp() {
filter = mock(Filter.class);
- robust = new RobustFilter(filter);
+ robust = new RobustFilter(
"filter",
filter);
source = mock(DOMSource.class);
}
source = mock(DOMSource.class);
}
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java
index 25327cb977d037e360c6a9e2683358fc1c6946b2..e3a0d470cf1368082ab972e99036c586b547fada 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/RobustTransformationTest.java
@@
-34,7
+34,7
@@
public class RobustTransformationTest {
@Before
public void setUp() {
transformation = mock(Transformation.class);
@Before
public void setUp() {
transformation = mock(Transformation.class);
- robust = new RobustTransformation(transformation);
+ robust = new RobustTransformation(
"transformation",
transformation);
source = mock(DOMSource.class);
resSource = mock(DOMSource.class);
}
source = mock(DOMSource.class);
resSource = mock(DOMSource.class);
}
diff --git
a/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
b/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
index 5d84107255f75ada0bf3702282f28239c1c9ef4f..e2e08b4a0e7b43c941d0711d81d1e8c7385de639 100644
(file)
--- a/
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
+++ b/
impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterFunctionTest.java
@@
-63,7
+63,7
@@
public class XMLRouterFunctionTest {
DocumentType type = mock(DocumentType.class);
when(type.isInstance(any(DOMSource.class))).thenReturn(true);
when(type.getName()).thenReturn(aType);
DocumentType type = mock(DocumentType.class);
when(type.isInstance(any(DOMSource.class))).thenReturn(true);
when(type.getName()).thenReturn(aType);
- RouterConfig routerConfig = configService.emptyConfig();
+ RouterConfig routerConfig = configService.emptyConfig(
"app"
);
routerConfig.documentTypeConfig().add(type);
return routerConfig;
}
routerConfig.documentTypeConfig().add(type);
return routerConfig;
}