diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-22 20:01:07 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-22 20:01:07 +0000 |
commit | bf3384faf9e5368f2af65f549bf036249cbf0a94 (patch) | |
tree | 7aa7ea30d9b493bba5ec1395413b4a08d409bc92 /branches/sca-java-1.3/modules | |
parent | 5a774754e30889efb10bbf99381ea979ce9c9b9f (diff) |
TUSCANY-2484 - Changes and tests for the case where a promoted reference has a multiplicity greater than 1. Not complete yet as this has thrown up a problem in that the promoting interface contract is not available to the promoted component. I was going to commit a fix with this change but backed it out to think a little more about it.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@678875 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3/modules')
-rw-r--r-- | branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java | 71 |
1 files changed, 46 insertions, 25 deletions
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 878799f989..b7fba86e07 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 @@ -27,6 +27,7 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; 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.Multiplicity; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; @@ -167,37 +168,57 @@ abstract class ReferenceConfigurationUtil { ComponentReference promotedReference, AssemblyFactory assemblyFactory, Monitor monitor) { - List<Binding> bindings = new ArrayList<Binding>(); - - // collect the top level bindings first - for (Binding binding : reference.getBindings()) { - if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) { - bindings.add(binding); - } - } - - // if there are not top level bindings to override the promoted bindings - // then collect the promoted bindings - if (bindings.size() == 0){ - for (Binding binding : promotedReference.getBindings()) { - if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) { - bindings.add(binding); - } - } - } else { - // TUSCANY-2324: if bindings are being replaced, use the matching interface contract - promotedReference.setInterfaceContract(reference.getInterfaceContract()); - } - - promotedReference.getBindings().clear(); - promotedReference.getBindings().addAll(bindings); - + if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) { + + // 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(); + + 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 + promotedReference.setInterfaceContract(reference.getInterfaceContract()); + } + } + + + } + if (promotedReference.getBindings().size() > 1) { warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName()); } + } else { + // 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: no such interface exists yet! + //promotedReference.setInterfaceContract(binding, reference.getInterfaceContract()); + } + } + } } + Set<Binding> callbackBindings = new HashSet<Binding>(); if (promotedReference.getCallback() != null) { callbackBindings.addAll(promotedReference.getCallback().getBindings()); |