git://wamblee.org
/
xmlrouter
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Now using RouterConfig internally inside the XML Router.
[xmlrouter]
/
impl
/
src
/
main
/
java
/
org
/
wamblee
/
xmlrouter
/
impl
/
XMLRouter.java
diff --git
a/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouter.java
b/impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouter.java
index 99b36354f1fa30a21d057b8995793c8b9283dddc..8fa78f4a18af15854b1c835dc4378daa44cee59d 100644
(file)
--- a/
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouter.java
+++ b/
impl/src/main/java/org/wamblee/xmlrouter/impl/XMLRouter.java
@@
-58,9
+58,9
@@
public class XMLRouter implements RouterConfig, Gateway, DestinationRegistry {
private Clock clock;
private AtomicLong nextEventId;
private Clock clock;
private AtomicLong nextEventId;
- private
Config<DocumentType> documentTypes
;
+ private
ExtendedRouterConfig routerConfig
;
private Transformations transformations;
private Transformations transformations;
- private Config<Filter> filters;
+
private Map<Id<Destination>, Destination> destinations;
public XMLRouter(Clock aClock, EventListener aListener) {
private Map<Id<Destination>, Destination> destinations;
public XMLRouter(Clock aClock, EventListener aListener) {
@@
-68,41
+68,36
@@
public class XMLRouter implements RouterConfig, Gateway, DestinationRegistry {
listener = aListener;
clock = aClock;
nextEventId = new AtomicLong(clock.currentTimeMillis());
listener = aListener;
clock = aClock;
nextEventId = new AtomicLong(clock.currentTimeMillis());
- documentTypes = new ConfigImpl<DocumentType>() {
- @Override
- public DocumentType wrap(Id<DocumentType> aId, DocumentType aType) {
- return new RobustDocumentType(aId, aType);
- }
- };
+ routerConfig = new SingleRouterConfig(sequenceNumbers);
transformations = new Transformations();
transformations = new Transformations();
- filters = new ConfigImpl<Filter>() {
- @Override
- public Filter wrap(Id<Filter> aId, Filter aFilter) {
- return new RobustFilter(aId, aFilter);
- }
- };
destinations = new LinkedHashMap<Id<Destination>, Destination>();
}
@Override
destinations = new LinkedHashMap<Id<Destination>, Destination>();
}
@Override
- public Config<DocumentType>
getD
ocumentTypeConfig() {
- return
documentTypes
;
+ public Config<DocumentType>
d
ocumentTypeConfig() {
+ return
routerConfig.documentTypeConfig()
;
}
@Override
}
@Override
- public Config<Transformation>
getT
ransformationConfig() {
- return
transformations.getT
ransformationConfig();
+ public Config<Transformation>
t
ransformationConfig() {
+ return
routerConfig.t
ransformationConfig();
}
@Override
}
@Override
- public Config<Filter>
getF
ilterConfig() {
- return
filters
;
+ public Config<Filter>
f
ilterConfig() {
+ return
routerConfig.filterConfig()
;
}
@Override
public void publish(String aSource, DOMSource aEvent) {
}
@Override
public void publish(String aSource, DOMSource aEvent) {
-
long time = clock.currentTimeMillis();
long time = clock.currentTimeMillis();
+
+ if (routerConfig.isDirty()) {
+ transformations.replaceTransformations(routerConfig
+ .transformationConfig().map());
+ routerConfig.resetDirty();
+ }
+
Id<DOMSource> id = new Id<DOMSource>(nextEventId.getAndIncrement());
List<String> types = determineDocumentTypes(aEvent);
EventInfo info = new EventInfo(time, aSource, id, types, aEvent);
Id<DOMSource> id = new Id<DOMSource>(nextEventId.getAndIncrement());
List<String> types = determineDocumentTypes(aEvent);
EventInfo info = new EventInfo(time, aSource, id, types, aEvent);
@@
-209,8
+204,7
@@
public class XMLRouter implements RouterConfig, Gateway, DestinationRegistry {
private boolean isAllowedByFilters(String aType, DOMSource aEvent) {
boolean allowed = true;
private boolean isAllowedByFilters(String aType, DOMSource aEvent) {
boolean allowed = true;
- for (Id<Filter> id : filters.ids()) {
- Filter filter = filters.get(id);
+ for (Filter filter : routerConfig.filterConfig().map().values()) {
if (!filter.isAllowed(aType, aEvent)) {
allowed = false;
}
if (!filter.isAllowed(aType, aEvent)) {
allowed = false;
}
@@
-220,8
+214,8
@@
public class XMLRouter implements RouterConfig, Gateway, DestinationRegistry {
private List<String> determineDocumentTypes(DOMSource aEvent) {
List<String> res = new ArrayList<String>();
private List<String> determineDocumentTypes(DOMSource aEvent) {
List<String> res = new ArrayList<String>();
- for (
Id<DocumentType> id : documentTypes.ids()) {
- DocumentType type = documentTypes.get(id);
+ for (
DocumentType type : routerConfig.documentTypeConfig().map()
+ .values()) {
if (type.isInstance(aEvent)) {
res.add(type.getName());
}
if (type.isInstance(aEvent)) {
res.add(type.getName());
}
@@
-229,13
+223,6
@@
public class XMLRouter implements RouterConfig, Gateway, DestinationRegistry {
return res;
}
return res;
}
- private void logEvent(String aMessage, String aSource, DOMSource aEvent,
- Exception aException) {
- LOGGER.log(Level.WARNING, aMessage + ": source '" + aSource +
- "': Event: '" + new XMLDocument(aEvent).print(true) + "'",
- aException);
- }
-
private void logEvent(String aMessage, String aSource, DOMSource aEvent) {
LOGGER.log(Level.WARNING,
aMessage + ": " + eventToString(aSource, aEvent));
private void logEvent(String aMessage, String aSource, DOMSource aEvent) {
LOGGER.log(Level.WARNING,
aMessage + ": " + eventToString(aSource, aEvent));