diff options
Diffstat (limited to '')
17 files changed, 116 insertions, 190 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java index 4532026050..30e2592008 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java @@ -65,13 +65,13 @@ public interface AbstractContract extends Base, Extensible, PolicySubject { * * @return true for a callback contract, false otherwise */ - boolean isCallback(); + boolean isForCallback(); /** * Sets a flag indicating whether this is a callback contract. * * @param isCallback true for a callback contract, false otherwise */ - void setIsCallback(boolean isCallback); + void setForCallback(boolean isCallback); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java index 6304ddb68a..731c2986b5 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java @@ -91,5 +91,20 @@ public interface Contract extends AbstractContract, PolicySubject, Cloneable { * @return the interface contract */ InterfaceContract getInterfaceContract(Binding binding); + + /** + * A flag to tell if there are any binding elements specified for this service or reference. + * If true, they override the the bindings in the corresponding reference/service in the + * component type or promoted reference/service. + * @return + */ + boolean isOverridingBindings(); + + /** + * Set the flag depending on if there are any binding elements specified for this service or + * reference. + * @param overridingBindings true if there are binding elements specified + */ + void setOverridingBindings(boolean overridingBindings); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java deleted file mode 100644 index 327d2d1901..0000000000 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.assembly.builder; - -/** - * Represent a binding that has been added automatically to the model rather - * than being specified by the user through the composite file - * - * @version $Rev$ $Date$ - * - */ -public interface AutomaticBinding extends Cloneable { - - /** - * @param isAutomatic - */ - void setIsAutomatic(boolean isAutomatic); - - /** - * @return isAutomatic - */ - boolean getIsAutomatic(); -} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java index b2debe6513..7f5ad695cd 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java @@ -31,13 +31,13 @@ import org.apache.tuscany.sca.assembly.ComponentProperty; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -172,7 +172,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { componentServices.put(uri, componentService); // count how many non-callback there are - if (!componentService.isCallback()) { + if (!componentService.isForCallback()) { if (nonCallbackServiceCount == 0) { nonCallbackService = componentService; @@ -221,7 +221,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // 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)) { + if ((!componentService.isForCallback()) && (!promotedService)) { // Check how many non callback non-promoted services we have if (nonCallbackServices == 0) { @@ -450,7 +450,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Connect each component reference to the corresponding reference for (ComponentReference componentReference : component.getReferences()) { - if (componentReference.getReference() != null || componentReference.isCallback()) { + if (componentReference.getReference() != null || componentReference.isForCallback()) { continue; } Reference reference = references.get(componentReference.getName()); @@ -468,7 +468,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { for (Reference reference : component.getImplementation().getReferences()) { if (!componentReferences.containsKey(reference.getName())) { ComponentReference componentReference = assemblyFactory.createComponentReference(); - componentReference.setIsCallback(reference.isCallback()); + componentReference.setForCallback(reference.isForCallback()); componentReference.setName(reference.getName()); componentReference.setReference(reference); component.getReferences().add(componentReference); @@ -557,7 +557,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // Connect each component service to the corresponding service for (ComponentService componentService : component.getServices()) { - if (componentService.getService() != null || componentService.isCallback()) { + if (componentService.getService() != null || componentService.isForCallback()) { continue; } Service service = services.get(componentService.getName()); @@ -574,7 +574,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { for (Service service : component.getImplementation().getServices()) { if (!componentServices.containsKey(service.getName())) { ComponentService componentService = assemblyFactory.createComponentService(); - componentService.setIsCallback(service.isCallback()); + componentService.setForCallback(service.isForCallback()); String name = service.getName(); componentService.setName(name); componentService.setService(service); @@ -625,14 +625,22 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - protected SCABinding createSCABinding(Definitions definitions) { - SCABinding scaBinding = scaBindingFactory.createSCABinding(); - - // mark the bindings that are added automatically so that they can - // be disregarded for overriding purposes - if (scaBinding instanceof AutomaticBinding) { - ((AutomaticBinding)scaBinding).setIsAutomatic(true); + protected void attachSCABinding(Contract contract, Definitions definitions) { + if (!contract.getBindings().isEmpty()) { + contract.setOverridingBindings(true); + // No need to set binding.sca + return; } + contract.setOverridingBindings(false); + + // Only add binding.sca for services + // FIXME: The latest OASIS spec only adds binding.sca to services + /* + if (!(contract instanceof Service)) { + return; + } + */ + SCABinding scaBinding = scaBindingFactory.createSCABinding(); if (definitions != null) { for (ExtensionType attachPointType : definitions.getBindingTypes()) { @@ -642,6 +650,6 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - return scaBinding; + contract.getBindings().add(scaBinding); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java index add4b09bb0..990b936c84 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java @@ -38,7 +38,6 @@ import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor; @@ -127,19 +126,13 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement // Set default binding names // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } + attachSCABinding(service, definitions); } // Initialize reference bindings for (Reference reference : composite.getReferences()) { // Create default SCA binding - if (reference.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - reference.getBindings().add(scaBinding); - } + attachSCABinding(reference, definitions); } // Initialize all component services and references @@ -199,20 +192,14 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement for (ComponentService componentService : component.getServices()) { // Create default SCA binding - if (componentService.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - componentService.getBindings().add(scaBinding); - } + attachSCABinding(componentService, definitions); } // Initialize reference bindings for (ComponentReference componentReference : component.getReferences()) { // Create default SCA binding - if (componentReference.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - componentReference.getBindings().add(scaBinding); - } + attachSCABinding(componentReference, definitions); } } } @@ -250,7 +237,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement */ private ComponentService createCallbackService(Component component, ComponentReference reference) { ComponentService componentService = assemblyFactory.createComponentService(); - componentService.setIsCallback(true); + componentService.setForCallback(true); componentService.setName(reference.getName()); try { InterfaceContract contract = (InterfaceContract)reference.getInterfaceContract().clone(); @@ -273,12 +260,12 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement // Set the promoted component from the promoted component of the composite reference implCompService .setPromotedComponent(((CompositeReference)implReference).getPromotedComponents().get(0)); - implCompService.setIsCallback(true); + implCompService.setForCallback(true); // Set the promoted service ComponentService promotedService = assemblyFactory.createComponentService(); promotedService.setName(((CompositeReference)implReference).getPromotedReferences().get(0).getName()); promotedService.setUnresolved(true); - promotedService.setIsCallback(true); + promotedService.setForCallback(true); implCompService.setPromotedService(promotedService); implService = implCompService; // Add the composite service to the composite implementation artifact @@ -343,7 +330,7 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement */ private ComponentReference createCallbackReference(Component component, ComponentService service) { ComponentReference componentReference = assemblyFactory.createComponentReference(); - componentReference.setIsCallback(true); + componentReference.setForCallback(true); componentReference.setName(service.getName()); try { InterfaceContract contract = (InterfaceContract)service.getInterfaceContract().clone(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index 5a9b53593a..bcc8821781 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -228,7 +228,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI if (uri == null) { // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint - if (!reference.isCallback() && (binding instanceof SCABinding)) + if (!reference.isForCallback() && (binding instanceof SCABinding)) continue; // create endpoint reference for manually configured bindings with a resolved endpoint to @@ -423,7 +423,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI Map<String, ComponentService> componentServices, List<Endpoint> endpoints) { // Only if this reference is a callback are there any endpoints of this kind - if (reference.isCallback()) { + if (reference.isForCallback()) { // add an unresolved endpoint reference with an unresolved endpoint to go with it // there will be one of these for each binding on the reference for (Binding binding : reference.getBindings()) { @@ -549,7 +549,7 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI if (uri == null) { // Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets // and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint - if (!reference.isCallback() && (binding instanceof SCABinding)) + if (!reference.isForCallback() && (binding instanceof SCABinding)) continue; // create an unwired endpoint containing the binding diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java index f97ed8d474..35876fa01f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java @@ -100,7 +100,7 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement break; } } - if (!promoted && !componentReference.isCallback()) { + if (!promoted && !componentReference.isForCallback()) { warning(monitor, "ReferenceWithoutTargets", composite, diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java index af572349a6..e15270911b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java @@ -40,7 +40,6 @@ import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; @@ -168,10 +167,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C // Set default binding names // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } + attachSCABinding(service, definitions); // Initialize binding names and URIs for (Binding binding : service.getBindings()) { @@ -211,10 +207,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C for (ComponentService service : component.getServices()) { // Create default SCA binding - if (service.getBindings().isEmpty()) { - SCABinding scaBinding = createSCABinding(definitions); - service.getBindings().add(scaBinding); - } + attachSCABinding(service, definitions); // Initialize binding names and URIs for (Binding binding : service.getBindings()) { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java index e29cef3ad9..2a9bdfc999 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java @@ -125,7 +125,7 @@ public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements Co String promotedComponentName = compositeService.getPromotedComponent().getName(); String promotedServiceName; if (componentService.getName() != null) { - if (compositeService.isCallback()) { + if (compositeService.isForCallback()) { // For callbacks the name already has the form "componentName"/"servicename" promotedServiceName = componentService.getName(); } else { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java index 7b9550f1b8..e5b7444bcf 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java @@ -23,13 +23,14 @@ import java.util.List; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Callback; 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.Contract; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; import org.apache.tuscany.sca.definitions.Definitions; @@ -68,9 +69,9 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil ComponentReference promotedReference = promotedRefs.get(0); // Set the bindings using the top level bindings to override the lower level bindings - if (bindingsSpecifiedManually(compositeReference.getBindings())) { + if (compositeReference.isOverridingBindings()) { compositeReference.setPromotionOverride(true); - } else if (bindingsSpecifiedManually(promotedReference.getBindings())) { + } else if (promotedReference.isOverridingBindings()) { compositeReference.getBindings().clear(); for (Binding binding : promotedReference.getBindings()) { try { @@ -82,11 +83,9 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } if (compositeReference.getInterfaceContract() != null && compositeReference.getInterfaceContract() .getCallbackInterface() != null) { - if (compositeReference.getCallback() != null && bindingsSpecifiedManually(compositeReference - .getCallback().getBindings())) { - compositeReference.setPromotionOverride(true); - } else if (promotedReference.getCallback() != null && bindingsSpecifiedManually(promotedReference - .getCallback().getBindings())) { + if (isCallbackOverridingBindings(compositeReference)) { + compositeReference.setPromotionOverride(true); + } else if (isCallbackOverridingBindings(promotedReference)) { if (compositeReference.getCallback() != null) { compositeReference.getCallback().getBindings().clear(); } else { @@ -106,9 +105,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil // Because the component reference bindings can all be different, we don't // copy any of them up to this composite reference, which will therefore always // have its own binding, even if it's only the default SCA binding. - if (bindingsSpecifiedManually(compositeReference.getBindings()) || (compositeReference - .getCallback() != null && bindingsSpecifiedManually(compositeReference.getCallback() - .getBindings()))) { + if (compositeReference.isOverridingBindings() || (compositeReference + .getCallback() != null && !compositeReference.getCallback().getBindings().isEmpty())) { compositeReference.setPromotionOverride(true); } } @@ -139,8 +137,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil ComponentReference promotedReference = promotedRefs.get(0); // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeReference.getBindings()) && bindingsSpecifiedManually(promotedReference - .getBindings())) { + if (!compositeReference.isOverridingBindings() && promotedReference + .isOverridingBindings()) { compositeReference.getBindings().clear(); for (Binding binding : promotedReference.getBindings()) { try { @@ -150,17 +148,16 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } } } - if (bindingsSpecifiedManually(componentReference.getBindings())) { + if (componentReference.isOverridingBindings()) { componentReference.setPromotionOverride(true); - } else if (bindingsSpecifiedManually(compositeReference.getBindings())) { + } else if (compositeReference.isOverridingBindings()) { componentReference.getBindings().clear(); componentReference.getBindings().addAll(compositeReference.getBindings()); } if (componentReference.getInterfaceContract() != null && componentReference .getInterfaceContract().getCallbackInterface() != null) { - if (!(compositeReference.getCallback() != null && bindingsSpecifiedManually(compositeReference - .getCallback().getBindings())) && promotedReference.getCallback() != null - && bindingsSpecifiedManually(promotedReference.getCallback().getBindings())) { + if (!isCallbackOverridingBindings(compositeReference) + && isCallbackOverridingBindings(promotedReference)) { if (compositeReference.getCallback() != null) { compositeReference.getCallback().getBindings().clear(); } else { @@ -169,11 +166,10 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil compositeReference.getCallback().getBindings().addAll(promotedReference .getCallback().getBindings()); } - if (componentReference.getCallback() != null && bindingsSpecifiedManually(componentReference - .getCallback().getBindings())) { + if (componentReference.getCallback() != null && !componentReference + .getCallback().getBindings().isEmpty()) { componentReference.setPromotionOverride(true); - } else if (compositeReference.getCallback() != null && bindingsSpecifiedManually(compositeReference - .getCallback().getBindings())) { + } else if (isCallbackOverridingBindings(compositeReference)) { if (componentReference.getCallback() != null) { componentReference.getCallback().getBindings().clear(); } else { @@ -194,9 +190,8 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil // Because the lower-level component reference bindings can all be different, // we don't copy any of them up to this component reference, which will therefore // always have its own binding, even if it's only the default SCA binding. - if (bindingsSpecifiedManually(componentReference.getBindings()) || (componentReference - .getCallback() != null && bindingsSpecifiedManually(componentReference - .getCallback().getBindings()))) { + if (componentReference.isOverridingBindings() + || isCallbackOverridingBindings(componentReference)) { componentReference.setPromotionOverride(true); } } @@ -206,26 +201,10 @@ public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuil } } } - - /** - * If the bindings are specified in the composite file return true as they should - * otherwise return false - * - * @param bindings - * @return true if the bindings were specified manually - */ - private boolean bindingsSpecifiedManually(List<Binding> bindings) { - - if (bindings.size() > 1) { - return true; - } else if (bindings.size() == 1 && bindings.get(0) instanceof AutomaticBinding - && ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { - return false; - } else if (bindings.size() == 1) { - return true; - } else { - return false; - } + + private boolean isCallbackOverridingBindings(Contract contract) { + Callback callback = contract.getCallback(); + return callback != null && !callback.getBindings().isEmpty(); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java index e251bcc25e..bed289c887 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java @@ -19,17 +19,16 @@ package org.apache.tuscany.sca.assembly.builder.impl; -import java.util.List; - import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Callback; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; import org.apache.tuscany.sca.definitions.Definitions; @@ -66,8 +65,7 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde if (promotedService != null) { // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && bindingsSpecifiedManually(promotedService - .getBindings())) { + if (!compositeService.isOverridingBindings() && promotedService.isOverridingBindings()) { compositeService.getBindings().clear(); for (Binding binding : promotedService.getBindings()) { try { @@ -79,9 +77,8 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } if (compositeService.getInterfaceContract() != null && compositeService.getInterfaceContract() .getCallbackInterface() != null) { - if (!(compositeService.getCallback() != null && bindingsSpecifiedManually(compositeService - .getCallback().getBindings())) && promotedService.getCallback() != null - && bindingsSpecifiedManually(promotedService.getCallback().getBindings())) { + if (!isCallbackOverridingBindings(compositeService) + && isCallbackOverridingBindings(promotedService)) { if (compositeService.getCallback() != null) { compositeService.getCallback().getBindings().clear(); } else { @@ -121,8 +118,7 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde if (promotedService != null) { // Set the bindings using the top level bindings to override the lower level bindings - if (!bindingsSpecifiedManually(compositeService.getBindings()) && bindingsSpecifiedManually(promotedService - .getBindings())) { + if (!compositeService.isOverridingBindings() && promotedService.isOverridingBindings()) { compositeService.getBindings().clear(); for (Binding binding : promotedService.getBindings()) { try { @@ -132,16 +128,14 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } } } - if (!bindingsSpecifiedManually(componentService.getBindings()) && bindingsSpecifiedManually(compositeService - .getBindings())) { + if (!componentService.isOverridingBindings() && compositeService.isOverridingBindings()) { componentService.getBindings().clear(); componentService.getBindings().addAll(compositeService.getBindings()); } if (componentService.getInterfaceContract() != null && componentService .getInterfaceContract().getCallbackInterface() != null) { - if (!(compositeService.getCallback() != null && bindingsSpecifiedManually(compositeService - .getCallback().getBindings())) && promotedService.getCallback() != null - && bindingsSpecifiedManually(promotedService.getCallback().getBindings())) { + if (!isCallbackOverridingBindings(compositeService) + && isCallbackOverridingBindings(promotedService)) { if (compositeService.getCallback() != null) { compositeService.getCallback().getBindings().clear(); } else { @@ -155,9 +149,7 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } } } - if (!(componentService.getCallback() != null && bindingsSpecifiedManually(componentService - .getCallback().getBindings())) && compositeService.getCallback() != null - && bindingsSpecifiedManually(compositeService.getCallback().getBindings())) { + if (!(isCallbackOverridingBindings(componentService)) && isCallbackOverridingBindings(compositeService)) { if (componentService.getCallback() != null) { componentService.getCallback().getBindings().clear(); } else { @@ -173,26 +165,10 @@ public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilde } } } - - /** - * If the bindings are specified in the composite file return true as they should - * otherwise return false - * - * @param bindings - * @return true if the bindings were specified manually - */ - private boolean bindingsSpecifiedManually(List<Binding> bindings) { - - if (bindings.size() > 1) { - return true; - } else if (bindings.size() == 1 && bindings.get(0) instanceof AutomaticBinding - && ((AutomaticBinding)bindings.get(0)).getIsAutomatic()) { - return false; - } else if (bindings.size() == 1) { - return true; - } else { - return false; - } + + private boolean isCallbackOverridingBindings(Contract contract) { + Callback callback = contract.getCallback(); + return callback != null && !callback.getBindings().isEmpty(); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java index 89c7bd1eb7..2b72f1f047 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java @@ -66,11 +66,11 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract { return requiredIntents; } - public boolean isCallback() { + public boolean isForCallback() { return isCallback; } - public void setIsCallback(boolean isCallback) { + public void setForCallback(boolean isCallback) { this.isCallback = isCallback; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java index af6e48959a..af4b3559c5 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java @@ -41,6 +41,7 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C private List<ComponentService> targets = new ArrayList<ComponentService>(); private Callback callback; private boolean promotionOverride; + private boolean overridingBindings; private List<EndpointReference> endpointReferences = new ArrayList<EndpointReference>(); /** @@ -132,4 +133,12 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C public String toString() { return getName(); } + + public boolean isOverridingBindings() { + return overridingBindings; + } + + public void setOverridingBindings(boolean overridingBindings) { + this.overridingBindings = overridingBindings; + } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java index eecb1bfb47..b67dbcbb12 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java @@ -30,7 +30,6 @@ import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.assembly.Extension; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; @@ -41,7 +40,7 @@ import org.apache.tuscany.sca.policy.PolicySubject; * * @version $Rev$ $Date$ */ -public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, OptimizableBinding, AutomaticBinding { +public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, OptimizableBinding { private String name; private String uri; private List<Object> extensions = new ArrayList<Object>(); @@ -55,8 +54,6 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op private Binding targetBinding; private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - private boolean isAutomatic = false; - public List<PolicySet> getApplicablePolicySets() { return applicablePolicySets; } @@ -160,14 +157,6 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op this.requiredIntents = intents; } - public void setIsAutomatic(boolean isAutomatic) { - this.isAutomatic = isAutomatic; - } - - public boolean getIsAutomatic() { - return this.isAutomatic; - } - @Override public Object clone() throws CloneNotSupportedException { return super.clone(); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java index 087d950fb6..62523e5c17 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java @@ -35,6 +35,7 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; */ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneable { private List<Binding> bindings = new ArrayList<Binding>(); + private boolean overridingBindings; private Callback callback; private List<Endpoint> endpoints = new ArrayList<Endpoint>(); @@ -94,4 +95,12 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab public List<Endpoint> getEndpoints() { return endpoints; } + + public boolean isOverridingBindings() { + return overridingBindings; + } + + public void setOverridingBindings(boolean overridingBindings) { + this.overridingBindings = overridingBindings; + } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java index 3b8309f573..46643f643b 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java @@ -186,7 +186,7 @@ public abstract class CompositeContext { List<ComponentService> services = component.getServices(); List<ComponentService> regularServices = new ArrayList<ComponentService>(); for (ComponentService service : services) { - if (service.isCallback()) { + if (service.isForCallback()) { continue; } String name = service.getName(); diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java index d0810efd10..1fa976cfb7 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java @@ -308,7 +308,7 @@ public class CompositeContextImpl extends CompositeContext { List<ComponentService> services = component.getServices(); List<ComponentService> regularServices = new ArrayList<ComponentService>(); for (ComponentService service : services) { - if (service.isCallback()) { + if (service.isForCallback()) { continue; } String name = service.getName(); |