summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java26
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java14
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java (renamed from sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java)10
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java (renamed from sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java)10
-rw-r--r--sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java96
-rw-r--r--sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java94
8 files changed, 161 insertions, 97 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
index 49aa6eb33f..270345fb5f 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
@@ -23,10 +23,12 @@ import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.binding.local.LocalSCABindingInvoker;
import org.apache.tuscany.sca.binding.sca.transform.BindingSCATransformer;
-import org.apache.tuscany.sca.binding.sca.transform.DefaultBindingSCATransformer;
+import org.apache.tuscany.sca.binding.sca.transform.SameDBCopyTransformer;
+import org.apache.tuscany.sca.binding.sca.transform.WSDLMediateTransformer;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.util.OperationDataBindingHelper;
import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
import org.apache.tuscany.sca.interfacedef.Compatibility;
import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
@@ -44,6 +46,10 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ServiceRuntimeException;
import org.oasisopen.sca.ServiceUnavailableException;
+/**
+*
+* @version $Rev$ $Date$
+*/
public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenceAsyncProvider {
private RuntimeEndpointReference endpointReference;
@@ -143,7 +149,7 @@ public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenc
} else {
throw new IllegalStateException();
}
- bindingTransformer = getBindingTransformer(operation, chain);
+ bindingTransformer = getBindingTransformer(operation, targetOp);
}
// it turns out that the chain source and target operations are
@@ -164,8 +170,20 @@ public class DefaultLocalSCAReferenceBindingProvider implements EndpointReferenc
return result;
}
- protected BindingSCATransformer getBindingTransformer(Operation operation, InvocationChain chain) {
- return new DefaultBindingSCATransformer(mediator, operation, chain);
+ protected BindingSCATransformer getBindingTransformer(Operation sourceOperation, Operation targetOperation) {
+ boolean differentDataBindings = OperationDataBindingHelper.isTransformationRequired(sourceOperation, targetOperation);
+
+ if (differentDataBindings) {
+ InterfaceContract bindingInterfaceContract = getWSDLBindingInterfaceContract();
+ if (!bindingInterfaceContract.getInterface().isRemotable()) {
+ throw new IllegalStateException("This method should only have been called for a remotable interface.");
+ }
+ Operation wsdlBindingOperation = interfaceContractMapper.map(bindingInterfaceContract.getInterface(), sourceOperation);
+ return new WSDLMediateTransformer(mediator, sourceOperation, wsdlBindingOperation, targetOperation);
+ } else {
+ return new SameDBCopyTransformer(mediator, sourceOperation, targetOperation);
+ }
+
}
@Override
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
index f9c1b05ab6..c0ed4e5559 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
@@ -28,6 +28,10 @@ import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+/**
+*
+* @version $Rev$ $Date$
+*/
public class XMLWFLocalSCABindingProviderFactory implements BindingProviderFactory<LocalSCABinding> {
private ExtensionPointRegistry extensionPoints;
private SCABindingMapper scaBindingMapper;
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
index 170908c82d..67783c1795 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
@@ -20,15 +20,17 @@
package org.apache.tuscany.sca.binding.local;
import org.apache.tuscany.sca.binding.sca.transform.BindingSCATransformer;
-import org.apache.tuscany.sca.binding.sca.transform.DefaultBindingSCATransformer;
-import org.apache.tuscany.sca.binding.sca.transform.XMLWFBindingSCATransformer;
+import org.apache.tuscany.sca.binding.sca.transform.WSDLMediateTransformer;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.provider.SCABindingMapper;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+/**
+*
+* @version $Rev$ $Date$
+*/
public class XMLWFLocalSCAReferenceBindingProvider extends DefaultLocalSCAReferenceBindingProvider {
public XMLWFLocalSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
@@ -37,12 +39,12 @@ public class XMLWFLocalSCAReferenceBindingProvider extends DefaultLocalSCARefere
super(extensionPoints, endpointReference, mapper);
}
- protected BindingSCATransformer getBindingTransformer(Operation operation, InvocationChain chain) {
+ protected BindingSCATransformer getBindingTransformer(Operation sourceOperation, Operation targetOperation) {
InterfaceContract bindingInterfaceContract = getWSDLBindingInterfaceContract();
if (!bindingInterfaceContract.getInterface().isRemotable()) {
throw new IllegalStateException("This method should only have been called for a remotable interface.");
}
- Operation wsdlBindingOperation = interfaceContractMapper.map(bindingInterfaceContract.getInterface(), operation);
- return new XMLWFBindingSCATransformer(mediator, operation, wsdlBindingOperation, chain);
+ Operation wsdlBindingOperation = interfaceContractMapper.map(bindingInterfaceContract.getInterface(), sourceOperation);
+ return new WSDLMediateTransformer(mediator, sourceOperation, wsdlBindingOperation, targetOperation);
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
index e84668fb1d..4a7b1d1cb8 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
@@ -19,6 +19,10 @@
package org.apache.tuscany.sca.binding.sca.transform;
+/**
+*
+* @version $Rev$ $Date$
+*/
public interface BindingSCATransformer {
Object transformInput(Object body);
Object transformOutput(Object body);
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java
index 77e93f8672..c4fc9b94a2 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java
@@ -23,16 +23,20 @@ import org.apache.tuscany.sca.databinding.Mediator;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
-public class DefaultBindingSCATransformer implements BindingSCATransformer {
+/**
+*
+* @version $Rev$ $Date$
+*/
+public class SameDBCopyTransformer implements BindingSCATransformer {
private Mediator mediator;
private Operation sourceOperation;
private Operation targetOperation;
- public DefaultBindingSCATransformer(Mediator mediator, Operation sourceOperation, InvocationChain chain) {
+ public SameDBCopyTransformer(Mediator mediator, Operation sourceOperation, Operation targetOperation) {
this.mediator = mediator;
this.sourceOperation = sourceOperation;
- this.targetOperation = chain.getTargetOperation();
+ this.targetOperation = targetOperation;
}
@Override
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java
index cc366c1f7a..7e36442d4e 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java
@@ -26,18 +26,22 @@ import org.apache.tuscany.sca.databinding.Mediator;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
-public class XMLWFBindingSCATransformer implements BindingSCATransformer {
+/**
+*
+* @version $Rev$ $Date$
+*/
+public class WSDLMediateTransformer implements BindingSCATransformer {
private Mediator mediator;
private Operation sourceOperation;
private Operation wsdlBindingOperation;
private Operation targetOperation;
- public XMLWFBindingSCATransformer(Mediator mediator, Operation sourceOperation, Operation wsdlBindingOperation, InvocationChain chain) {
+ public WSDLMediateTransformer(Mediator mediator, Operation sourceOperation, Operation wsdlBindingOperation, Operation targetOperation) {
this.mediator = mediator;
this.sourceOperation = sourceOperation;
this.wsdlBindingOperation = wsdlBindingOperation;
- this.targetOperation = chain.getTargetOperation();
+ this.targetOperation = targetOperation;
}
@Override
diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
index bdb4d6fa08..29a4551a5a 100644
--- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
+++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.databinding.Mediator;
-import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.databinding.util.OperationDataBindingHelper;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
@@ -48,86 +48,6 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor {
this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
}
- public boolean isTransformationRequired(DataType source, DataType target) {
- if (source == null || target == null) { // void return type
- return false;
- }
- if (source == target) {
- return false;
- }
-
- // Output type can be null
- if (source == null && target == null) {
- return false;
- } else if (source == null || target == null) {
- return true;
- }
- String sourceDataBinding = source.getDataBinding();
- String targetDataBinding = target.getDataBinding();
- if (sourceDataBinding == targetDataBinding) {
- return false;
- }
- if (sourceDataBinding == null || targetDataBinding == null) {
- // TODO: If any of the databinding is null, then no transformation
- return false;
- }
- return !sourceDataBinding.equals(targetDataBinding);
- }
-
- public boolean isTransformationRequired(Operation source, Operation target) {
- if (source == target) {
- return false;
- }
-
- if (source.isWrapperStyle() != target.isWrapperStyle()) {
- return true;
- }
-
- // Check output type
- List<DataType> sourceOutputType = source.getOutputType().getLogical();
- List<DataType> targetOutputType = target.getOutputType().getLogical();
-
- int outputSize = sourceOutputType.size();
- if ( outputSize != targetOutputType.size() ) {
- return true;
- }
-
- for (int i = 0; i < outputSize; i++) {
- if (isTransformationRequired(sourceOutputType.get(i), targetOutputType.get(i))) {
- return true;
- }
- }
-
- List<DataType> sourceInputType = source.getInputType().getLogical();
- List<DataType> targetInputType = target.getInputType().getLogical();
-
- int size = sourceInputType.size();
- if (size != targetInputType.size()) {
- // TUSCANY-1682: The wrapper style may have different arguments
- return true;
- }
- for (int i = 0; i < size; i++) {
- if (isTransformationRequired(sourceInputType.get(i), targetInputType.get(i))) {
- return true;
- }
- }
-
- return false;
- }
-
- private boolean isTransformationRequired(InterfaceContract sourceContract,
- Operation sourceOperation,
- InterfaceContract targetContract,
- Operation targetOperation) {
- if (targetContract == null) {
- targetContract = sourceContract;
- }
- if (sourceContract == targetContract) {
- return false;
- }
- return isTransformationRequired(sourceOperation, targetOperation);
- }
-
public void process(RuntimeEndpoint endpoint) {
InterfaceContract sourceContract = endpoint.getBindingInterfaceContract();
InterfaceContract targetContract = endpoint.getComponentTypeServiceInterfaceContract();
@@ -185,5 +105,19 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor {
}
}
+
+
+ private boolean isTransformationRequired(InterfaceContract sourceContract,
+ Operation sourceOperation,
+ InterfaceContract targetContract,
+ Operation targetOperation) {
+ if (targetContract == null) {
+ targetContract = sourceContract;
+ }
+ if (sourceContract == targetContract) {
+ return false;
+ }
+ return OperationDataBindingHelper.isTransformationRequired(sourceOperation, targetOperation);
+ }
}
diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
new file mode 100644
index 0000000000..56c32ef2b6
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
@@ -0,0 +1,94 @@
+/*
+ * 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.databinding.util;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+*
+* @version $Rev$ $Date$
+*/
+public class OperationDataBindingHelper {
+
+ private static boolean isTransformationRequired(DataType source, DataType target) {
+ if (source == null || target == null) { // void return type
+ return false;
+ }
+ if (source == target) {
+ return false;
+ }
+
+ String sourceDataBinding = source.getDataBinding();
+ String targetDataBinding = target.getDataBinding();
+ if (sourceDataBinding == targetDataBinding) {
+ return false;
+ }
+ if (sourceDataBinding == null || targetDataBinding == null) {
+ // TODO: If any of the databinding is null, then no transformation
+ return false;
+ }
+ return !sourceDataBinding.equals(targetDataBinding);
+ }
+
+ public static boolean isTransformationRequired(Operation source, Operation target) {
+ if (source == target) {
+ return false;
+ }
+
+ if (source.isWrapperStyle() != target.isWrapperStyle()) {
+ return true;
+ }
+
+ // Check output type
+ List<DataType> sourceOutputType = source.getOutputType().getLogical();
+ List<DataType> targetOutputType = target.getOutputType().getLogical();
+
+ int outputSize = sourceOutputType.size();
+ if ( outputSize != targetOutputType.size() ) {
+ return true;
+ }
+
+ for (int i = 0; i < outputSize; i++) {
+ if (isTransformationRequired(sourceOutputType.get(i), targetOutputType.get(i))) {
+ return true;
+ }
+ }
+
+ List<DataType> sourceInputType = source.getInputType().getLogical();
+ List<DataType> targetInputType = target.getInputType().getLogical();
+
+ int size = sourceInputType.size();
+ if (size != targetInputType.size()) {
+ // TUSCANY-1682: The wrapper style may have different arguments
+ return true;
+ }
+ for (int i = 0; i < size; i++) {
+ if (isTransformationRequired(sourceInputType.get(i), targetInputType.get(i))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
+