summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-02-21 11:29:58 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-02-21 11:29:58 +0000
commite4d4979293ce33727d6867b7304ab5c693af39ba (patch)
treed4a633a098500fb272147dd36833ea471bfc47af /sca-java-2.x/trunk/modules
parent02951937a75982962471a0b77a99ce1e179832bd (diff)
TUSCANY-4005 - swap the test around so that the code that raises an error if a reference target containing only a component name matches a component with multiple services comes after the code that matches interfaces and policy
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1291714 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java38
1 files changed, 23 insertions, 15 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 c1eaf98e66..cd8115d201 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
@@ -416,16 +416,24 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
matchedEndpoint = endpoints.get(0);
}
} else {
- // find the first endpoint that matches this endpoint reference
+ // find the endpoints that match this endpoint reference
+ List<Endpoint> matchedEndpoints = new ArrayList<Endpoint>();
+
+ for (Endpoint endpoint : endpoints){
+ if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
+ haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit)){
+ matchedEndpoints.add(endpoint);
+ }
+ }
// TUSCANY-4005 - raise an error if a reference target that only specifies the
// component name matches more than one component service
if (endpointReference.getTargetEndpoint().getService() == null &&
endpointReference.getTargetEndpoint().getBinding() == null &&
- endpoints.size() > 1 ) {
+ matchedEndpoints.size() > 1 ) {
String serviceName = null;
- for (Endpoint endpoint : endpoints){
+ for (Endpoint endpoint : matchedEndpoints){
// ignore service names called "default" as these indicate dynamic services
// created for the likes of implementation.python
if (serviceName == null &&
@@ -458,8 +466,6 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
}
}
}
-
- boolean findTargetSCABinding = false;
// TUSCANY-3941 check for the case where the user has provided a
// binding.sca at the reference and make sure we pick
@@ -467,16 +473,18 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// other bindings are provided
if (endpointReference.getBinding() != null &&
endpointReference.getBinding() instanceof SCABinding ){
- findTargetSCABinding = true;
- }
-
- for (Endpoint endpoint : endpoints){
- if (haveMatchingPolicy(endpointReference, endpoint, matchAudit, builderContext) &&
- haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit) &&
- (findTargetSCABinding == false ||
- (findTargetSCABinding == true && endpoint.getBinding() instanceof SCABinding))){
- matchedEndpoint = endpoint;
- break;
+ for (Endpoint endpoint : matchedEndpoints){
+ if (endpoint.getBinding() instanceof SCABinding){
+ matchedEndpoint = endpoint;
+ break;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null) {
+ // just take the first matched endpoint from the list
+ if (matchedEndpoints.size() > 0){
+ matchedEndpoint = matchedEndpoints.get(0);
}
}
}