From 4f538657ed8baff04cdf01adff8db3c7e82aa3b9 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 23 Jun 2011 12:57:26 +0000 Subject: TUSCANY-3878 - check policy language equality based on the namspace of the policy element rather than the full element QName git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1138859 13f79535-47bb-0310-9956-ffa450edef68 --- .../builder/impl/ComponentPolicyBuilderImpl.java | 6 ++-- .../builder/impl/CompositePolicyBuilderImpl.java | 39 +++++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) (limited to 'sca-java-2.x/trunk/modules/builder/src/main/java/org/apache') diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java index 6ce0a3a7d5..9e6c4d758d 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentPolicyBuilderImpl.java @@ -558,14 +558,14 @@ public class ComponentPolicyBuilderImpl { } } - protected Set getPolicyNames(PolicySubject subject) { + protected Set getPolicyNames(PolicySubject subject) { if (subject == null) { return Collections.emptySet(); } - Set names = new HashSet(); + Set names = new HashSet(); for (PolicySet ps : subject.getPolicySets()) { for (PolicyExpression exp : ps.getPolicies()) { - names.add(exp.getName()); + names.add(exp.getName().getNamespaceURI()); } } return names; 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 9c4da518d7..2dc149ed60 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 @@ -42,6 +42,7 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicyExpression; import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySubject; import org.apache.tuscany.sca.policy.util.PolicyHelper; @@ -410,7 +411,7 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple for (ComponentService componentService : component.getServices()) { for (Endpoint ep : componentService.getEndpoints()) { - Set policyNames = getPolicyNames(ep); + Set policyNames = getPolicyNames(ep); // check that only one policy language is present in the endpoint's policy sets if (policyNames.size() > 1){ @@ -420,19 +421,21 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple ep.toString(), policyNames.toString()); } else { - for (QName policyType : policyNames) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(ep, context); + for (PolicySet ps : ep.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + PolicyBuilder builder = builders.getPolicyBuilder(exp.getName()); + if (builder != null) { + builder.build(ep, context); + } } - } + } } } } for (ComponentReference componentReference : component.getReferences()) { for (EndpointReference epr : componentReference.getEndpointReferences()) { - Set policyNames = getPolicyNames(epr); + Set policyNames = getPolicyNames(epr); // check that only one policy language is present in the endpoint references's policy sets if (policyNames.size() > 1){ @@ -442,10 +445,12 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple epr.toString(), policyNames.toString()); } else { - for (QName policyType : policyNames) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(epr, context); + for (PolicySet ps : epr.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + PolicyBuilder builder = builders.getPolicyBuilder(exp.getName()); + if (builder != null) { + builder.build(epr, context); + } } } } @@ -454,7 +459,7 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple Implementation implementation = component.getImplementation(); if (implementation != null) { - Set policyNames = getPolicyNames(implementation); + Set policyNames = getPolicyNames(implementation); // check that only one policy language is present in the implementations's policy sets if (policyNames.size() > 1){ @@ -464,10 +469,12 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple component.toString(), policyNames.toString()); } else { - for (QName policyType : policyNames) { - PolicyBuilder builder = builders.getPolicyBuilder(policyType); - if (builder != null) { - builder.build(component, implementation, context); + for (PolicySet ps : implementation.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + PolicyBuilder builder = builders.getPolicyBuilder(exp.getName()); + if (builder != null) { + builder.build(component, implementation, context); + } } } } -- cgit v1.2.3