summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-07-04 23:20:36 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-07-04 23:20:36 +0000
commit7d30e4d1c5eeef8a326d076b962c925d54ad33ad (patch)
treea509709f7d6294492e49ef624fb87a643c17874f /java/sca/modules/assembly/src
parent8ef57fdf120e8c1fe5e802e412961831ce70b1f7 (diff)
TUSCANY-2352 - upgrade the fix for promoted binding overriding as the automatically created sca bindings were causing the top level to always override.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@674139 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly/src')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java39
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java84
2 files changed, 107 insertions, 16 deletions
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
new file mode 100644
index 0000000000..97708f9ef5
--- /dev/null
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
@@ -0,0 +1,39 @@
+/*
+ * 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/BaseConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
index 2868116048..71523bd713 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
@@ -41,6 +41,7 @@ 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.ComponentPreProcessor;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
import org.apache.tuscany.sca.definitions.SCADefinitions;
@@ -827,25 +828,35 @@ public abstract class BaseConfigurationBuilderImpl {
newComponentService.setService(promotedService.getService());
// set the bindings using the top level bindings to override the
// lower level bindings
- if (compositeService.getBindings().size() > 0){
+ if (bindingsSpecifiedManually(compositeService.getBindings())){
newComponentService.getBindings()
.addAll(compositeService.getBindings());
} else {
- newComponentService.getBindings()
- .addAll(promotedService.getBindings());
+ for (Binding binding : promotedService.getBindings()){
+ try {
+ newComponentService.getBindings().add((Binding)binding.clone());
+ } catch(CloneNotSupportedException ex){
+ // this binding can't be used in the promoted service
+ }
+ }
}
newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
if (compositeService.getInterfaceContract() != null && compositeService
.getInterfaceContract().getCallbackInterface() != null) {
newComponentService.setCallback(assemblyFactory.createCallback());
if ((compositeService.getCallback() != null) &&
- (compositeService.getCallback().getBindings().size() > 0)){
+ (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
newComponentService.getCallback().getBindings()
.addAll(compositeService.getCallback().getBindings());
} else if ((promotedService.getCallback() != null) &&
- (promotedService.getCallback().getBindings().size() > 0)){
- newComponentService.getBindings()
- .addAll(promotedService.getBindings());
+ (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
+ for (Binding binding : promotedService.getCallback().getBindings()){
+ try {
+ newComponentService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch(CloneNotSupportedException ex){
+ // this binding can't be used in the promoted service
+ }
+ }
}
}
@@ -904,20 +915,28 @@ public abstract class BaseConfigurationBuilderImpl {
newComponentService.setName("$promoted$." + componentService.getName());
promotedComponent.getServices().add(newComponentService);
newComponentService.setService(promotedService.getService());
+
// set the bindings using the top level bindings to override the
// lower level bindings
- if (componentService.getBindings().size() > 0){
+ if (bindingsSpecifiedManually(componentService.getBindings())){
newComponentService.getBindings()
.addAll(componentService.getBindings());
- } else if (compositeService.getBindings().size() > 0){
+ } else if (bindingsSpecifiedManually(compositeService.getBindings())){
newComponentService.getBindings()
.addAll(compositeService.getBindings());
} else {
- newComponentService.getBindings()
- .addAll(promotedService.getBindings());
+ for (Binding binding : promotedService.getBindings()){
+ try {
+ newComponentService.getBindings().add((Binding)binding.clone());
+ } catch(CloneNotSupportedException ex){
+ // this binding can't be used in the promoted service
+ }
+ }
}
+
newComponentService.setInterfaceContract(componentService
.getInterfaceContract());
+
if (componentService.getInterfaceContract() != null &&
componentService.getInterfaceContract().getCallbackInterface() != null) {
@@ -926,17 +945,22 @@ public abstract class BaseConfigurationBuilderImpl {
// set the bindings using the top level bindings to override the
// lower level bindings
if ((componentService.getCallback() != null) &&
- (componentService.getCallback().getBindings().size() > 0)){
+ (bindingsSpecifiedManually(componentService.getCallback().getBindings()))){
newComponentService.getCallback().getBindings()
.addAll(componentService.getCallback().getBindings());
} else if ((compositeService.getCallback() != null) &&
- (compositeService.getCallback().getBindings().size() > 0)){
+ (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
newComponentService.getCallback().getBindings()
.addAll(compositeService.getCallback().getBindings());
} else if ((promotedService.getCallback() != null) &&
- (promotedService.getCallback().getBindings().size() > 0)){
- newComponentService.getBindings()
- .addAll(promotedService.getBindings());
+ (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
+ for (Binding binding : promotedService.getCallback().getBindings()){
+ try {
+ newComponentService.getCallback().getBindings().add((Binding)binding.clone());
+ } catch(CloneNotSupportedException ex){
+ // this binding can't be used in the promoted service
+ }
+ }
}
}
@@ -952,6 +976,28 @@ public abstract class BaseConfigurationBuilderImpl {
}
/**
+ * 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() == true )){
+ return false;
+ } else if (bindings.size() == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
* @param composite
*/
private void configureSourcedProperties(Composite composite, List<ComponentProperty> propertySettings) {
@@ -1023,6 +1069,12 @@ public abstract class BaseConfigurationBuilderImpl {
private SCABinding createSCABinding() {
SCABinding scaBinding = scaBindingFactory.createSCABinding();
+ // mark the bindings that are added automatically so that theu can
+ // can be disregarded for overriding purposes
+ if (scaBinding instanceof AutomaticBinding){
+ ((AutomaticBinding)scaBinding).setIsAutomatic(true);
+ }
+
if ( policyDefinitions != null ) {
for ( IntentAttachPointType attachPointType : policyDefinitions.getBindingTypes() ) {
if ( attachPointType.getName().equals(BINDING_SCA_QNAME)) {