summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-04-09 15:55:49 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-04-09 15:55:49 +0000
commit27bb15967a7e8124b586bc4fa278f7f534e69b5e (patch)
tree056645006283a9da8114f82e0110030503c82dd4
parent2900675aa56f7cc1f62d21a0cdd91a9e10003865 (diff)
TUSCANY-3531 - validate that composite reference don't override nonOverridable component references
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@932474 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties1
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java32
2 files changed, 31 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties b/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
index 7958acfec4..8e6b351ea4 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
@@ -75,3 +75,4 @@ PropertXSDTypesDontMatch = [ASM_5036] The property component {0} property {1} ha
PropertXSDElementsDontMatch = [ASM_5036] The property component {0} property {1} has XSD element {2} while its component type property has the XSD element {3}
IntentNotSatisfied = The intent {0} associated with policy subject {1} has no matching policy set
URIFoundOnServiceSCABinding = [ASM90005] The SCA binding {0} on component {1} service {2} should not have a URI and the URI is currently set to {3}
+CompositeReferencePromotesNonOverridableReference = [ASM50042] Composite reference promotes component reference with 1..1 multiplicity and nonOverridable flag set true: Composite = {0} Composite reference = {1} Component reference = {2}
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
index ddcfc883d6..2ea35ffb9b 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
@@ -267,6 +267,9 @@ public class CompositeComponentTypeBuilderImpl {
// promote multiplicity
reconcileReferenceMultiplicity(componentType, compositeReference, promotedComponentReference, monitor);
+
+ // check nonOverridable
+ validateNonOverridable(componentType, compositeReference, promotedComponentReference, monitor);
// promote interface contracts
calculatePromotedReferenceInterfaceContract(compositeReference, promotedComponentReference, monitor);
@@ -586,6 +589,31 @@ public class CompositeComponentTypeBuilderImpl {
} else {
return true;
}
- }
-
+ }
+
+ /**
+ * ASM50042 - Checks that if a component reference with multiplicity="1..1" is marked
+ * as nonOveridable then there are no composite references that promote it
+ *
+ * @param componentType
+ * @param compositeReference
+ * @param promotedComponentReference
+ * @param monitor
+ */
+ private void validateNonOverridable(ComponentType componentType,
+ Reference compositeReference,
+ Reference promotedComponentReference,
+ Monitor monitor){
+ if ((promotedComponentReference.getMultiplicity() == Multiplicity.ONE_ONE) &&
+ (((ComponentReference)promotedComponentReference)).isNonOverridable() == true) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "CompositeReferencePromotesNonOverridableReference",
+ componentType.getURI(),
+ compositeReference.getName(),
+ promotedComponentReference.getName());
+ }
+ }
+
} //end class