diff options
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; |