From 89e8211b2b8ddb262dffbd2dc338a6fa7d4c140b Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 5 Oct 2009 13:14:17 +0000 Subject: Add back in duplicate name checking that got lost during the re-org. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@821787 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/builder/impl/ComponentBuilderImpl.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'java/sca/modules/builder/src/main') diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 3b3560e46f..17c1db038c 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -176,6 +176,7 @@ public class ComponentBuilderImpl { // look at each component service in turn and calculate its // configuration based on OASIS rules for (ComponentService componentService : component.getServices()) { + Service componentTypeService = componentService.getService(); if (componentTypeService == null) { @@ -308,6 +309,16 @@ public class ComponentBuilderImpl { // Create a component service for each service if (component.getImplementation() != null) { for (Service service : component.getImplementation().getServices()) { + // check for duplicate service names in implementation + if (service != component.getImplementation().getService(service.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateImplementationServiceName", + component.getName(), + service.getName()); + } + ComponentService componentService = (ComponentService)component.getService(service.getName()); // if the component doesn't have a service with the same name as the @@ -328,6 +339,16 @@ public class ComponentBuilderImpl { // Create a component reference for each reference if (component.getImplementation() != null) { for (Reference reference : component.getImplementation().getReferences()) { + // check for duplicate reference names in implementation + if (reference != component.getImplementation().getReference(reference.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateImplementationReferenceName", + component.getName(), + reference.getName()); + } + ComponentReference componentReference = (ComponentReference)component.getReference(reference.getName()); // if the component doesn't have a reference with the same name as the @@ -348,6 +369,15 @@ public class ComponentBuilderImpl { // Create component property for each property if (component.getImplementation() != null) { for (Property property : component.getImplementation().getProperties()) { + // check for duplicate property names in implementation + if (property != component.getImplementation().getProperty(property.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateImplementationPropertyName", + component.getName(), + property.getName()); + } ComponentProperty componentProperty = (ComponentProperty)component.getProperty(property.getName()); // if the component doesn't have a property with the same name as @@ -371,6 +401,16 @@ public class ComponentBuilderImpl { // Connect each component service to the corresponding component type service for (ComponentService componentService : component.getServices()) { + // check for duplicate service names in component + if (componentService != component.getService(componentService.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateComponentServiceName", + component.getName(), + componentService.getName()); + } + if (componentService.getService() != null || componentService.isForCallback()) { continue; } @@ -399,6 +439,16 @@ public class ComponentBuilderImpl { // Connect each component reference to the corresponding component type reference for (ComponentReference componentReference : component.getReferences()) { + // check for duplicate reference names in component + if (componentReference != component.getReference(componentReference.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateComponentReferenceName", + component.getName(), + componentReference.getName()); + } + if (componentReference.getReference() != null || componentReference.isForCallback()) { continue; } @@ -426,7 +476,18 @@ public class ComponentBuilderImpl { private void connectPropertiesToComponentType(Component component) { // Connect each component property to the corresponding component type property for (ComponentProperty componentProperty : component.getProperties()) { + // check for duplicate property names in component + if (componentProperty != component.getProperty(componentProperty.getName())){ + Monitor.error(monitor, + this, + "assembly-validation-messages", + "DuplicateComponentPropertyName", + component.getName(), + componentProperty.getName()); + } + Property property = component.getImplementation().getProperty(componentProperty.getName()); + if (property != null) { componentProperty.setProperty(property); } else { -- cgit v1.2.3