diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-18 20:48:27 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-18 20:48:27 +0000 |
commit | e713ab6f04e4e967fb62a17b8f129abee8c63ebd (patch) | |
tree | 75a9f010e07525ff362d1bb2707f1a6fc01999fe /sca-java-2.x/trunk/modules | |
parent | 74e7c014ea9d312fef584694bbfa64154b76ab68 (diff) |
Check that the policy sets for a particular endpoint, endpointreference or implementation are expressed in one language.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@900548 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 54 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java index 5b5d2a8089..60d62610a1 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.builder.impl; +import java.util.Set; + import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.Component; @@ -178,10 +180,22 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple for (ComponentService componentService : component.getServices()) { for (Endpoint ep : componentService.getEndpoints()) { - for (QName policyType : getPolicyNames(ep)) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(ep, context); + Set<QName> policyNames = getPolicyNames(ep); + + // check that only one policy language is present in the endpoint's policy sets + if (policyNames.size() > 1){ + Monitor.error(context.getMonitor(), + this, + "builder-validation-messages", + "MultiplePolicyLanguagesInEP", + ep.toString(), + policyNames.toString()); + } else { + for (QName policyType : policyNames) { + PolicyBuilder builder = builders.getPolicyBuilder(policyType); + if (builder != null) { + builder.build(ep, context); + } } } } @@ -189,10 +203,22 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple for (ComponentReference componentReference : component.getReferences()) { for (EndpointReference epr : componentReference.getEndpointReferences()) { - for (QName policyType : getPolicyNames(epr)) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(epr, context); + Set<QName> policyNames = getPolicyNames(epr); + + // check that only one policy language is present in the endpoint references's policy sets + if (policyNames.size() > 1){ + Monitor.error(context.getMonitor(), + this, + "builder-validation-messages", + "MultiplePolicyLanguagesInEPR", + epr.toString(), + policyNames.toString()); + } else { + for (QName policyType : policyNames) { + PolicyBuilder builder = builders.getPolicyBuilder(policyType); + if (builder != null) { + builder.build(epr, context); + } } } } @@ -200,10 +226,22 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple Implementation implementation = component.getImplementation(); if (implementation != null) { - for (QName policyType : getPolicyNames(implementation)) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(component, implementation, context); + Set<QName> policyNames = getPolicyNames(implementation); + + // check that only one policy language is present in the implementations's policy sets + if (policyNames.size() > 1){ + Monitor.error(context.getMonitor(), + this, + "builder-validation-messages", + "MultiplePolicyLanguagesInImplementation", + component.toString(), + policyNames.toString()); + } else { + for (QName policyType : policyNames) { + PolicyBuilder builder = builders.getPolicyBuilder(policyType); + if (builder != null) { + builder.build(component, implementation, context); + } } } } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties b/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties index 214a134d9c..69d8fb0903 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/builder/src/main/resources/org/apache/tuscany/sca/builder/builder-validation-messages.properties @@ -22,4 +22,7 @@ # there are a whole stack of builder related messages that # are still yet to be moved here from assembly-validation-messages.properties PolicyAttachedToProperty = [POL40002] The policy {0} has been attached to a property or one of its children. This is not allowed. -PolicyDOMModelMissmatch = The DOM node which has been found as a result of evaluating the XPath attachment of policy {0} cannot be mapped back to an element in the SCA model. The structural URI of the node is {1} +PolicyDOMModelMissmatch = The DOM node which has been found as a result of evaluating the XPath attachment of policy {0} cannot be mapped back to an element in the SCA model. The structural URI of the node is {1} +MultiplePolicyLanguagesInEP = The policy sets for endpoint {0} contain policies specified in more than one language {1} +MultiplePolicyLanguagesInEPR = The policy sets for endpoint reference {0} contain policies specified in more than one language {1} +MultiplePolicyLanguagesInImpl = The policy sets for component {0} implementation contain policies specified in more than one language {1} |