diff options
author | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-04 06:16:29 +0000 |
---|---|---|
committer | bdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-04 06:16:29 +0000 |
commit | 31e3272d6a6a0cb361f1e1e77c152e7c15de7612 (patch) | |
tree | 0b59973c164beeec109bb9ab0c9a5b5c53a8af9c /sca-java-2.x/trunk/modules/builder/src | |
parent | 94d85abe8a454d55dc98e278c33dd089f48b4ac1 (diff) |
Fix the removal of direct policy sets when external policy sets are attached. Also, allow policy sets to attach externally to interface elements.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@982130 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/builder/src')
2 files changed, 18 insertions, 3 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 51c23f0939..2a88a48c8c 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 @@ -365,14 +365,16 @@ public class CompositePolicyBuilderImpl extends ComponentPolicyBuilderImpl imple BuilderContext context) { boolean foundExternalPolicySet = false; for (PolicySet ps : subject.getPolicySets() ) { - if ( ps.getAttachTo() != null ) + if ( ps.isExternalAttachment() ) { foundExternalPolicySet = true; + break; + } } if ( foundExternalPolicySet ) { List<PolicySet> copy = new ArrayList<PolicySet>(subject.getPolicySets()); for ( PolicySet ps : copy ) { - if ( ps.getAttachTo() == null ) { + if ( !ps.isExternalAttachment() ) { subject.getPolicySets().remove(ps); } } diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java index 5d30c048ec..3930ac0e43 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java @@ -182,6 +182,7 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { String index = getStructuralURI(node); PolicySubject subject = lookup(composite, index); if (subject != null) { + ps.setIsExternalAttachment(true); subject.getPolicySets().add(ps); } else { // raise a warning that the XPath node didn't match a node in the @@ -270,6 +271,12 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { Element component = (Element)node.getParentNode(); String uri = component.getAttributeNS(null, "uri"); return uri + "#implementation()"; + } else if (localName.startsWith("interface.")) { + Element contract = (Element)node.getParentNode(); + String contractName = contract.getAttributeNS(null, "name"); + Element component = (Element)node.getParentNode().getParentNode(); + String uri = component.getAttributeNS(null, "uri"); + return uri + "#" + contractName + "#interface()"; //(" + contractName + "/" + interfaceName + ")" } } } @@ -296,6 +303,7 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { String service = null; String reference = null; String binding = null; + boolean isInterface = false; boolean impl = false; if (index != -1) { @@ -323,6 +331,9 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { service = path; } else if ("reference".equals(prefix)) { reference = path; + } else if ( prefix.indexOf("#interface") != -1 ) { + service = prefix.substring(0, prefix.indexOf("#interface")); + isInterface = true; } } } @@ -331,7 +342,9 @@ public class PolicyAttachmentBuilderImpl implements CompositeBuilder { if (component.getURI().equals(componentURI)) { if (service != null) { ComponentService componentService = component.getService(service); - if (binding != null) { + if ( isInterface ) { + return componentService.getInterfaceContract().getInterface(); + } else if (binding != null) { Binding b = getBinding(componentService, binding); if (b instanceof PolicySubject) { return (PolicySubject)b; |