summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java13
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties1
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java4
3 files changed, 14 insertions, 4 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
index a911020474..1f8fbd2d21 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
@@ -41,15 +41,24 @@ public class CompositeModelResolver implements ModelResolver {
private Contribution contribution;
private Map<QName, Composite> map = new HashMap<QName, Composite>();
+ private Monitor monitor;
public CompositeModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories, Monitor monitor) {
this.contribution = contribution;
+ this.monitor = monitor;
}
public void addModel(Object resolved) {
Composite composite = (Composite)resolved;
- // FIXME: What if two composites with the same QName are added?
- map.put(composite.getName(), composite);
+ if (map.containsKey(composite.getName())){
+ Monitor.error(monitor,
+ this,
+ "assembly-validation-messages",
+ "DuplicateCompositeName",
+ composite.getName().toString());
+ } else {
+ map.put(composite.getName(), composite);
+ }
}
public Object removeModel(Object resolved) {
diff --git a/java/sca/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties b/java/sca/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
index 8cc5e5a5ec..8e80fd8231 100644
--- a/java/sca/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
+++ b/java/sca/modules/assembly-xml/src/main/resources/assembly-xml-validation-messages.properties
@@ -27,3 +27,4 @@ PolicyServiceValidationException = PolicyValidation exceptions when processing s
ContributionReadException = ContributionReadException occured due to : {0}
ContributionWriteException = ContributionWriteException occured due to : {0}
XMLStreamException = XMLStreamException occured due to : {0}
+DuplicateCompositeName = Found more than one composite with the name : {0}
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
index 8c4ebabe79..e81e244458 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -318,8 +318,7 @@ public class NodeFactoryImpl extends NodeFactory {
attached = true;
}
contribution.getDeployables().add(composite);
- // REVIEW: Is it needed?
- contribution.getModelResolver().addModel(composite);
+
return attached;
}
@@ -541,6 +540,7 @@ public class NodeFactoryImpl extends NodeFactory {
for (Composite composite : contribution.getDeployables()) {
// Include the node composite in the top-level composite
tempComposite.getIncludes().add(composite);
+ logger.log(Level.INFO, "Adding composite: " + composite.getName() + " to domain");
}
}