Author: slaws
Date: Mon Sep 12 09:33:18 2011
New Revision: 1169664
URL: http://svn.apache.org/viewvc?rev=1169664&view=rev
Log:
TUSCANY-3941 - If a reference specifies target in an SCA binding then we expect
there to be an SCA binding at the service. In this case don't just select the
first binding in the list.
Modified:
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
Modified:
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java?rev=1169664&r1=1169663&r2=1169664&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
Mon Sep 12 09:33:18 2011
@@ -325,6 +325,11 @@ public class EndpointReferenceBuilderImp
// 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
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1169664&r1=1169663&r2=1169664&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Mon Sep 12 09:33:18 2011
@@ -413,9 +413,22 @@ public class EndpointReferenceBinderImpl
}
} 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;
}
Modified:
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite?rev=1169664&r1=1169663&r2=1169664&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/client/src/main/resources/helloworld-client.composite
Mon Sep 12 09:33:18 2011
@@ -22,10 +22,17 @@ xmlns:tuscany="http://tuscany.apache.org
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"/>
Modified:
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java?rev=1169664&r1=1169663&r2=1169664&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/driver/src/test/java/itest/CrossContribTestCase.java
Mon Sep 12 09:33:18 2011
@@ -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
Modified:
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite?rev=1169664&r1=1169663&r2=1169664&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
(original)
+++
tuscany/sca-java-2.x/trunk/testing/itest/data-copy/service/src/main/resources/helloworld-service.composite
Mon Sep 12 09:33:18 2011
@@ -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>