diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-02 13:14:54 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-02 13:14:54 +0000 |
commit | 4c5fe5e40520e6902ed0827ebb9829d6f1c43bb6 (patch) | |
tree | b410065a6731e2d31d911d2f97fbe75ef81b2c9a /sca-java-2.x/trunk/modules/core | |
parent | b891ba6824e932c01e6103446dc87346b780c02d (diff) |
TUSCANY-4005 - raise an error if a reference target containing only a component name matches a component with multiple services.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1239597 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core')
2 files changed, 48 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 263fdcecbe..c1eaf98e66 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 @@ -244,7 +244,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { selectForwardEndpoint(endpointReference, endpointReference.getTargetEndpoint().getService().getEndpoints(), matchAudit, - builderContext); + builderContext, + runtime); if (hasCallback(endpointReference)){ selectCallbackEndpoint(endpointReference, @@ -265,7 +266,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { selectForwardEndpoint(endpointReference, endpoints, matchAudit, - builderContext); + builderContext, + runtime); // If the reference was matched try to match the callback if (endpointReference.getStatus().equals(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED) && @@ -402,7 +404,7 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { * @param endpointReference * @param endpoints */ - private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit, BuilderContext builderContext) { + private void selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints, Audit matchAudit, BuilderContext builderContext, boolean runtime) { Endpoint matchedEndpoint = null; @@ -415,6 +417,48 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder { } } else { // find the first endpoint that matches this endpoint reference + + // 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 ) { + + String serviceName = null; + for (Endpoint endpoint : endpoints){ + // ignore service names called "default" as these indicate dynamic services + // created for the likes of implementation.python + if (serviceName == null && + !endpoint.getService().getName().equals("default")){ + serviceName = endpoint.getService().getName(); + } + + if (serviceName != null && + !endpoint.getService().getName().equals("default") && + !endpoint.getService().getName().equals(serviceName)){ + if (runtime){ + Monitor.error(monitor, + this, + "endpoint-validation-messages", + "TooManyTargetServices", + endpointReference.toString(), + endpointReference.getTargetEndpoint().toString(), + matchAudit); + throw new ServiceRuntimeException("Unable to bind " + + monitor.getLastProblem().toString()); + } else { + Monitor.warning(monitor, + this, + "endpoint-validation-messages", + "TooManyTargetServices", + endpointReference.toString(), + endpointReference.getTargetEndpoint().toString()); + return; + } + } + } + } + boolean findTargetSCABinding = false; // TUSCANY-3941 check for the case where the user has provided a diff --git a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties index 5c9e01ffdc..f300010bd4 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties @@ -22,3 +22,4 @@ NoEndpointsFound = No endpoints found in the domain that match the reference {0} EndpointReferenceCantBeMatched = Unable to match the endpoint reference {0} with the policy of the service to which it refers, matching process was {1} # Single quote (we'll) needs to be escaped as we''ll ComponentReferenceTargetNotFound = Component reference target not found at deployment time, it might be a remote service elsewhere in the SCA Domain so we''ll try and resolve it again at runtime: {0} +TooManyTargetServices = [ASM60048] A component reference {0} with only the target component service name specified {1} matches more than one service
\ No newline at end of file |