summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java5
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java15
-rw-r--r--sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite9
-rw-r--r--sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java22
-rw-r--r--sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite2
5 files changed, 50 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
index 4463248164..5dc0e40684 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
@@ -325,6 +325,11 @@ public class EndpointReferenceBuilderImpl {
// so that the binder can test it against the fully populated
// registry
endpoint = createEndpoint(component, uri);
+ if (binding instanceof SCABinding) {
+ // TUSCANY-3941
+ // if it's an SCA binding we store it to influence the matching at runtime
+ endpointRef.setBinding(binding);
+ }
endpointRef.setStatus(EndpointReference.Status.WIRED_TARGET_IN_BINDING_URI);
} catch (Exception ex) {
// the target string definitely isn't an SCA target string
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 2a3e466b60..179c60a829 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
@@ -413,9 +413,22 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
}
} else {
// find the first endpoint that matches this endpoint reference
+ 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
+ // a binding.sca at the service regardless of how many
+ // 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)){
+ haveMatchingInterfaceContracts(endpointReference, endpoint, matchAudit) &&
+ (findTargetSCABinding == false ||
+ (findTargetSCABinding == true && endpoint.getBinding() instanceof SCABinding))){
matchedEndpoint = endpoint;
break;
}
diff --git a/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite b/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
index 461ec33c89..5108e1eae1 100644
--- a/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
+++ b/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
@@ -22,10 +22,17 @@ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://itest"
name="ClientComposite">
- <component name="ClientSCA">
+ <component name="ClientSCAAlternative">
<implementation.java class="itest.client.impl.ClientImpl"/>
<reference name="service" target="Service"/>
</component>
+
+ <component name="ClientSCA">
+ <implementation.java class="itest.client.impl.ClientImpl"/>
+ <reference name="service">
+ <binding.sca uri="Service"/>
+ </reference>
+ </component>
<component name="ClientWS">
<implementation.java class="itest.client.impl.ClientImpl"/>
diff --git a/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java b/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
index d94115a1e4..cc1f542769 100644
--- a/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
+++ b/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
@@ -25,8 +25,12 @@ import itest.common.intf.ClientIntf;
import java.net.URI;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
@@ -52,6 +56,24 @@ public class CrossContribTestCase {
assertNotNull(client);
client.callJAXBCrossContribution();
}
+
+ // TUSCANY-3941 - make sure binding.sca is matched properly when
+ // it's used to carry the target URI. Not much to do with
+ // JAXB but this is a convenient test
+ @Test
+ public void testJAXBCrossContributionSCAAlternative() throws Exception {
+ ClientIntf client = node.getService(ClientIntf.class, "ClientSCAAlternative");
+ assertNotNull(client);
+ client.callJAXBCrossContribution();
+
+ // Get the binding from the ClientSCA component
+ Binding binding = ((NodeImpl)node).getDomainComposite().getComponents().get(2).getReferences().get(0).getEndpointReferences().get(0).getBinding();
+ assertEquals(true, binding instanceof SCABinding);
+
+ // Get the binding from the ClientSCAAlternative component
+ Binding alternativeBinding = ((NodeImpl)node).getDomainComposite().getComponents().get(1).getReferences().get(0).getEndpointReferences().get(0).getBinding();
+ assertEquals(true, alternativeBinding instanceof WebServiceBinding);
+ }
@Test
diff --git a/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite b/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
index 14a7801cf1..78b49eaa2c 100644
--- a/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
+++ b/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
@@ -25,8 +25,8 @@
<component name="Service">
<implementation.java class="itest.service.impl.ServiceImpl"/>
<service name="ServiceIntf">
- <binding.sca name="sca"/>
<binding.ws name="ws" uri="http://localhost:8085/Service/ServiceIntf"/>
+ <binding.sca name="sca"/>
<tuscany:binding.rmi name="rmi" uri="rmi://localhost:8099/Service"/>
</service>
</component>