diff options
4 files changed, 62 insertions, 16 deletions
diff --git a/java/sca/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java b/java/sca/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java index 027b5a6968..c6e46564f0 100644 --- a/java/sca/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java +++ b/java/sca/itest/recursive-ws/src/test/java/bindingoverride/BindingOverrideTestCase.java @@ -50,7 +50,7 @@ public class BindingOverrideTestCase{ } @Test - @Ignore("TUSCANY-2352") + //@Ignore("TUSCANY-2352") public void test() throws Exception { Assert.assertEquals("Target: Hello Target: Hello Fred!!", targetClient.hello("Fred")); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java index 571088f88d..2868116048 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java @@ -825,14 +825,27 @@ public abstract class BaseConfigurationBuilderImpl { newComponentService.setName("$promoted$." + compositeService.getName()); promotedComponent.getServices().add(newComponentService); newComponentService.setService(promotedService.getService()); - newComponentService.getBindings().addAll(compositeService.getBindings()); + // set the bindings using the top level bindings to override the + // lower level bindings + if (compositeService.getBindings().size() > 0){ + newComponentService.getBindings() + .addAll(compositeService.getBindings()); + } else { + newComponentService.getBindings() + .addAll(promotedService.getBindings()); + } newComponentService.setInterfaceContract(compositeService.getInterfaceContract()); if (compositeService.getInterfaceContract() != null && compositeService .getInterfaceContract().getCallbackInterface() != null) { newComponentService.setCallback(assemblyFactory.createCallback()); - if (compositeService.getCallback() != null) { - newComponentService.getCallback().getBindings().addAll(compositeService - .getCallback().getBindings()); + if ((compositeService.getCallback() != null) && + (compositeService.getCallback().getBindings().size() > 0)){ + newComponentService.getCallback().getBindings() + .addAll(compositeService.getCallback().getBindings()); + } else if ((promotedService.getCallback() != null) && + (promotedService.getCallback().getBindings().size() > 0)){ + newComponentService.getBindings() + .addAll(promotedService.getBindings()); } } @@ -891,16 +904,39 @@ public abstract class BaseConfigurationBuilderImpl { newComponentService.setName("$promoted$." + componentService.getName()); promotedComponent.getServices().add(newComponentService); newComponentService.setService(promotedService.getService()); - newComponentService.getBindings() - .addAll(componentService.getBindings()); + // set the bindings using the top level bindings to override the + // lower level bindings + if (componentService.getBindings().size() > 0){ + newComponentService.getBindings() + .addAll(componentService.getBindings()); + } else if (compositeService.getBindings().size() > 0){ + newComponentService.getBindings() + .addAll(compositeService.getBindings()); + } else { + newComponentService.getBindings() + .addAll(promotedService.getBindings()); + } newComponentService.setInterfaceContract(componentService .getInterfaceContract()); - if (componentService.getInterfaceContract() != null && componentService - .getInterfaceContract().getCallbackInterface() != null) { + if (componentService.getInterfaceContract() != null && + componentService.getInterfaceContract().getCallbackInterface() != null) { + newComponentService.setCallback(assemblyFactory.createCallback()); - if (componentService.getCallback() != null) { + + // set the bindings using the top level bindings to override the + // lower level bindings + if ((componentService.getCallback() != null) && + (componentService.getCallback().getBindings().size() > 0)){ newComponentService.getCallback().getBindings() .addAll(componentService.getCallback().getBindings()); + } else if ((compositeService.getCallback() != null) && + (compositeService.getCallback().getBindings().size() > 0)){ + newComponentService.getCallback().getBindings() + .addAll(compositeService.getCallback().getBindings()); + } else if ((promotedService.getCallback() != null) && + (promotedService.getCallback().getBindings().size() > 0)){ + newComponentService.getBindings() + .addAll(promotedService.getBindings()); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java index 16132070b9..34deb0dc41 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java @@ -166,19 +166,29 @@ class BaseWireBuilderImpl { ComponentService nonCallbackService = null; int nonCallbackServices = 0; for (ComponentService componentService : component.getServices()) { - + // Index component services by component name / service name String uri = component.getName() + '/' + componentService.getName(); componentServices.put(uri, componentService); - if (!componentService.isCallback()) { + + boolean promotedService = false; + if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) { + promotedService = true; + } + + // count how many non-callback, non-promoted services there are + // if there is only one the component name also acts as the service name + if ((!componentService.isCallback()) && (!promotedService)) { - // Check how many non callback services we have + // Check how many non callback non-promoted services we have if (nonCallbackServices == 0) { nonCallbackService = componentService; } nonCallbackServices++; } + } + if (nonCallbackServices == 1) { // If we have a single non callback service, index it by // component name as well diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java index 76c8146654..dd80312b4b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java @@ -129,11 +129,11 @@ public class CompositeBuilderImpl implements CompositeBuilder { // Build composite service binding-related information compositeServiceBindingBuilder.build(composite); - // Wire the components - componentWireBuilder.build(composite); - // Configure composite services compositeServiceConfigurationBuilder.build(composite); + + // Wire the components + componentWireBuilder.build(composite); // Wire the composite references compositeReferenceWireBuilder.build(composite); |