summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-23 06:13:25 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-23 06:13:25 +0000
commit0b29e46291e31be846fabe25ce3cf9ee9e40ce5c (patch)
tree5f611f84e6199ecf59ea1bfc26e0fe449974f024 /sca-java-2.x
parent45fca891240513321adbae08af4a58c149be148a (diff)
Remove constrained intents from endpoint references at runtime binding time
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@966983 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index b58635d6d1..2b59e892be 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -49,6 +49,7 @@ import org.apache.tuscany.sca.interfacedef.util.Audit;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -559,8 +560,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// this they must be satisfied by reference policy sets
// Failing this the intent is unresolved and the reference and
// service don't match
- List<Intent> eprIntents = new ArrayList<Intent>();
- eprIntents.addAll(endpointReference.getRequiredIntents());
+
+
// TODO - seems that we should do this loop on a binding by binding basis
// rather than each time we do matching
@@ -573,6 +574,13 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
}
}
+ // Before we start examining intents, remove any whose constrained
+ // types don't include the binding type
+ removeConstrainedIntents(endpointReference, bindingType);
+
+ List<Intent> eprIntents = new ArrayList<Intent>();
+ eprIntents.addAll(endpointReference.getRequiredIntents());
+
// first check the binding type
for (Intent intent : endpointReference.getRequiredIntents()){
if (bindingType != null &&
@@ -703,7 +711,33 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
return match;
}
- protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){
+ // Copied from ComponentPolicyBuilder, should probably be refactored
+ protected void removeConstrainedIntents(EndpointReference subject, BindingType bindingType) {
+ List<Intent> intents = subject.getRequiredIntents();
+
+ // Remove the intents whose @contrains do not include the current element
+ if(bindingType != null){
+ List<Intent> copy = new ArrayList<Intent>(intents);
+ for (Intent i : copy) {
+ if (i.getConstrainedTypes().size() > 0){
+ boolean constraintFound = false;
+ for (ExtensionType constrainedType : i.getConstrainedTypes()){
+ if (constrainedType.getType().equals(bindingType.getType()) ||
+ constrainedType.getType().equals(bindingType.getBaseType())){
+ constraintFound = true;
+ break;
+ }
+ }
+ if(!constraintFound){
+ intents.remove(i);
+ }
+ }
+ }
+ }
+ }
+
+
+ protected boolean isQualifiedBy(Intent qualifiableIntent, Intent qualifiedIntent){
if (qualifiedIntent.getQualifiableIntent() == qualifiableIntent){
return true;
} else {