diff options
Diffstat (limited to 'branches')
11 files changed, 107 insertions, 44 deletions
diff --git a/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12.composite b/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12.composite index 23799f8487..cc2ea5b0e2 100644 --- a/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12.composite +++ b/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12.composite @@ -30,6 +30,7 @@ </reference> <reference name="reference1a" promote="ComponentB/reference2a"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> + <binding.ws uri="http://foo.com/bar"/> </reference> <component name="ComponentB"> @@ -43,7 +44,7 @@ <reference name="reference2"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> </reference> - <reference name="reference2a" target="ComponentF"> + <reference name="reference2a"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> </reference> </component> diff --git a/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12a.composite b/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12a.composite index 59ed4d02f4..54eee7d657 100644 --- a/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12a.composite +++ b/branches/sca-java-1.3/itest/builder/src/main/resources/scenario12/scenario12a.composite @@ -42,11 +42,9 @@ </service> <service name="Service3a"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> - <binding.ws uri="http://foo.com/bar" /> </service> <reference name="reference3" target="ComponentD/Service3a"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> - <binding.ws/> </reference> <reference name="reference3a" target="ComponentE"> <!-- bindings and/or interfaces may or may not be specified explicitly here --> diff --git a/branches/sca-java-1.3/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/branches/sca-java-1.3/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java index e19ed92b42..f3ffd44cdb 100644 --- a/branches/sca-java-1.3/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java +++ b/branches/sca-java-1.3/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java @@ -50,7 +50,7 @@ public class BuilderTestCase extends TestCase { protected void tearDown() throws Exception {
}
-
+
// Scenario 1: <binding.ws> on outer composite service CompositeA/Service1
public void testScenario1() throws Exception {
System.out.println("====>Running testScenario1");
@@ -779,7 +779,7 @@ public class BuilderTestCase extends TestCase { componentRef = reference;
assertTrue(reference.getBindings().size() == 2);
assertTrue(reference.getBindings().get(0) instanceof SCABinding);
- assertTrue(reference.getBindings().get(1) instanceof SCABinding);
+ assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
}
}
assertTrue(componentRef != null);
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java index f1522688fc..ee63497fbe 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java @@ -20,6 +20,8 @@ package org.apache.tuscany.sca.assembly; import java.util.List; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + /** * Represents an endpoint (primarily a combination of a target service name and a set of * candidate bindings) @@ -147,5 +149,19 @@ public interface Endpoint extends Base, Cloneable { * * @param binding target binding */ - void setTargetBinding(Binding binding); + void setTargetBinding(Binding binding); + + /** + * Returns the interface contract defining the interface + * + * @return the interface contract + */ + InterfaceContract getInterfaceContract(); + + /** + * Sets the interface contract defining the interface + * + * @param interfaceContract the interface contract + */ + void setInterfaceContract(InterfaceContract interfaceContract); } diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java index 9c0dd62dff..0c2d02ab48 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java @@ -424,6 +424,7 @@ class BaseWireBuilderImpl { endpoint.setTargetName(targetComponent.getName()); endpoint.setSourceComponent(null); // TODO - fixed up at start endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.setTargetComponent(targetComponent); endpoint.setTargetComponentService(targetComponentService); endpoint.getCandidateBindings().addAll(componentReference.getBindings()); @@ -477,7 +478,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(targetComponent.getName()); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.setTargetComponent(targetComponent); endpoint.setTargetComponentService(targetComponentService); endpoint.getCandidateBindings().addAll(componentReference.getBindings()); @@ -498,7 +500,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(name); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.getCandidateBindings().addAll(componentReference.getBindings()); endpoints.add(endpoint); @@ -536,7 +539,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(targetComponent.getName()); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.setTargetComponent(targetComponent); endpoint.setTargetComponentService(targetComponentService); endpoint.getCandidateBindings().addAll(componentReference.getBindings()); @@ -560,7 +564,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(name); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.getCandidateBindings().addAll(componentReference.getBindings()); endpoints.add(endpoint); @@ -625,7 +630,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(targetComponent.getName()); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.setTargetComponent(targetComponent); endpoint.setTargetComponentService(targetComponentService); endpoint.getCandidateBindings().add(binding); @@ -643,7 +649,8 @@ class BaseWireBuilderImpl { Endpoint endpoint = endpointFactory.createEndpoint(); endpoint.setTargetName(uri); endpoint.setSourceComponent(null); // TODO - fixed up at start - endpoint.setSourceComponentReference(componentReference); + endpoint.setSourceComponentReference(componentReference); + endpoint.setInterfaceContract(componentReference.getInterfaceContract()); endpoint.setSourceBinding(binding); endpoints.add(endpoint); } diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java index e2677e5a82..c0702c87b3 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionWireBuilderImpl.java @@ -28,6 +28,7 @@ import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.Reference; @@ -43,10 +44,12 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; + private EndpointFactory endpointFactory; private Monitor monitor; - public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory, Monitor monitor) { + public ComponentReferencePromotionWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) { this.assemblyFactory = assemblyFactory; + this.endpointFactory = endpointFactory; this.monitor = monitor; } @@ -91,7 +94,7 @@ public class ComponentReferencePromotionWireBuilderImpl implements CompositeBuil ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { ReferenceConfigurationUtil.reconcileReferenceBindings( - componentReference, promotedReference, assemblyFactory, monitor); + componentReference, promotedReference, assemblyFactory, endpointFactory, monitor); if (componentReference.getInterfaceContract() != null && // can be null in unit tests componentReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java index 0e8585cc91..fd1c3d2a8f 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java @@ -99,8 +99,8 @@ public class CompositeBuilderImpl implements CompositeBuilder { compositeIncludeBuilder = new CompositeIncludeBuilderImpl(monitor); componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor); - componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, monitor); - compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, monitor); + componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory, monitor); + compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, monitor); compositeCloneBuilder = new CompositeCloneBuilderImpl(monitor); componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor); compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java index be579387ca..8aa1897311 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceWireBuilderImpl.java @@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; @@ -40,10 +41,12 @@ import org.apache.tuscany.sca.monitor.Monitor; */ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { private AssemblyFactory assemblyFactory; + private EndpointFactory endpointFactory; private Monitor monitor; - public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, Monitor monitor) { + public CompositeReferenceWireBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, Monitor monitor) { this.assemblyFactory = assemblyFactory; + this.endpointFactory = endpointFactory; this.monitor = monitor; } @@ -68,7 +71,7 @@ public class CompositeReferenceWireBuilderImpl implements CompositeBuilder { ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference); for (ComponentReference promotedReference : promotedReferences) { ReferenceConfigurationUtil.reconcileReferenceBindings( - compositeReference, promotedReference, assemblyFactory, monitor); + compositeReference, promotedReference, assemblyFactory, endpointFactory, monitor); if (compositeReference.getInterfaceContract() != null && // can be null in unit tests compositeReference.getInterfaceContract().getCallbackInterface() != null) { SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class); diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java index c7418913ed..23d547efaf 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java @@ -28,6 +28,7 @@ import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointFactory; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; @@ -167,6 +168,7 @@ abstract class ReferenceConfigurationUtil { static void reconcileReferenceBindings(Reference reference, ComponentReference promotedReference, AssemblyFactory assemblyFactory, + EndpointFactory endpointFactory, Monitor monitor) { if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || @@ -175,26 +177,40 @@ abstract class ReferenceConfigurationUtil { // if necessary override the promoted endpoints (and bindings) with the top level bindings if (reference.getBindings().size() > 0 ){ - if (reference instanceof ComponentReference){ - promotedReference.getEndpoints().clear(); - promotedReference.getEndpoints().addAll(((ComponentReference)reference).getEndpoints()); - } - - promotedReference.getBindings().clear(); + List<Binding> bindingsToCopyDown = new ArrayList<Binding>(); + List<Endpoint> endpointsToCopyDown = new ArrayList<Endpoint>(); for (Binding binding : reference.getBindings()) { if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) { - promotedReference.getBindings().add(binding); - // TUSCANY-2324: ensure that the promoted reference can identify the - // correct interface contract for this binding - // TODO - Remove and use Reference.getInterfaceContract(binding) - // in any binding that needs to use the interface contract - // from the promoting reference - promotedReference.setInterfaceContract(reference.getInterfaceContract()); + bindingsToCopyDown.add(binding); + + if (reference instanceof ComponentReference){ + for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){ + if ( endpoint.getSourceBinding() == binding){ + endpointsToCopyDown.add(endpoint); + break; + } + } + } else { + // create a new endpoint to represent this promoted binding + Endpoint endpoint = endpointFactory.createEndpoint(); + endpoint.setTargetName(binding.getURI()); + endpoint.setSourceComponent(null); // TODO - fixed up at start + endpoint.setSourceComponentReference(promotedReference); + endpoint.setInterfaceContract(reference.getInterfaceContract()); + endpoint.setSourceBinding(binding); + endpointsToCopyDown.add(endpoint); + } } } - + if (bindingsToCopyDown.size() > 0) { + promotedReference.getBindings().clear(); + promotedReference.getBindings().addAll(bindingsToCopyDown); + + promotedReference.getEndpoints().clear(); + promotedReference.getEndpoints().addAll(endpointsToCopyDown); + } } if (promotedReference.getBindings().size() > 1) { @@ -204,21 +220,29 @@ abstract class ReferenceConfigurationUtil { // if necessary merge the promoted endpoints (and bindings) with the top level bindings if (reference.getBindings().size() > 0 ){ - if (reference instanceof ComponentReference){ - promotedReference.getEndpoints().addAll(((ComponentReference)reference).getEndpoints()); - } - for (Binding binding : reference.getBindings()) { if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) { promotedReference.getBindings().add(binding); - // TUSCANY-2324: ensure that the promoted reference can identify the - // correct interface contract for this binding - // TODO: use Reference.getInterfaceContract(binding) when the interface contract is required - // in any binding that needs to use the interface contract - // from the promoting reference - //promotedReference.setInterfaceContract(binding, reference.getInterfaceContract()); + + if (reference instanceof ComponentReference){ + for (Endpoint endpoint : ((ComponentReference)reference).getEndpoints()){ + if ( endpoint.getSourceBinding() == binding){ + promotedReference.getEndpoints().add(endpoint); + break; + } + } + } else { + // create a new endpoint to represent this promoted binding + Endpoint endpoint = endpointFactory.createEndpoint(); + endpoint.setTargetName(binding.getURI()); + endpoint.setSourceComponent(null); // TODO - fixed up at start + endpoint.setSourceComponentReference(promotedReference); + endpoint.setInterfaceContract(reference.getInterfaceContract()); + endpoint.setSourceBinding(binding); + promotedReference.getEndpoints().add(endpoint); + } } - } + } } } diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java index 250db31cb6..ea9f768f4e 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java @@ -100,7 +100,7 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe for (Endpoint theEndpoint : endpoints){ if (theEndpoint.getSourceBinding() == binding){ - interfaceContract = theEndpoint.getSourceComponentReference().getInterfaceContract(); + interfaceContract = theEndpoint.getInterfaceContract(); } } diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java index 4396967137..5748abb07d 100644 --- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java +++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java @@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; /** * The assembly model object for an endpoint. @@ -48,6 +49,8 @@ public class EndpointImpl implements Endpoint { private Binding targetBinding; private Binding targetCallbackBinding; + private InterfaceContract interfaceContract; + protected EndpointImpl() { } @@ -140,4 +143,12 @@ public class EndpointImpl implements Endpoint { public void setTargetCallbackBinding(Binding targetCallbackBinding){ this.targetCallbackBinding = targetCallbackBinding; } + + public InterfaceContract getInterfaceContract() { + return interfaceContract; + } + + public void setInterfaceContract(InterfaceContract interfaceContract) { + this.interfaceContract = interfaceContract; + } } |