diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-18 12:52:25 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-18 12:52:25 +0000 |
commit | 124f75b6ac090f38120c4e1f94e86d7fdbe8fe00 (patch) | |
tree | e034e76f0083d2163868a05c49b4703d9ff7d1a5 /java/sca/modules | |
parent | 9e2093af171365bd300c93b757a2ab53ac41609d (diff) |
Raise an error if two composites with the same name are found (ASM_6001). Also remove code marked with FIXME that causes composites to be added twice under normal conditions.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@805398 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
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"); } } |