tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scottk...@apache.org
Subject svn commit: r1153285 - in /tuscany/sca-java-2.x/trunk/modules: binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/ binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/ core-databinding/src/main/java/org/ap...
Date Tue, 02 Aug 2011 21:55:22 GMT
Author: scottkurz
Date: Tue Aug  2 21:55:21 2011
New Revision: 1153285

URL: http://svn.apache.org/viewvc?rev=1153285&view=rev
Log:
TUSCANY-3894.  Factor out introspection for same vs. different databindings on operation from
DBRuntimeWireProcessor to new OperationDataBindingHelper util.   Use this in DefaultLocalSCAReferenceBindingProvider
to do a Mediator.copyXXX for same-databinding operations, while doing a Mediator.mediateXXX
with a WSDL operation for different-databinding operations.

Added:
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java
      - copied, changed from r1153160, tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java
      - copied, changed from r1153160, tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
Removed:
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
    tuscany/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java?rev=1153285&r1=1153284&r2=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/DefaultLocalSCAReferenceBindingProvider.java
Tue Aug  2 21:55:21 2011
@@ -23,10 +23,12 @@ import org.apache.tuscany.sca.assembly.E
 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.Ru
 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 DefaultLocalSCAReferenceBin
                     } 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 DefaultLocalSCAReferenceBin
         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

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java?rev=1153285&r1=1153284&r2=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCABindingProviderFactory.java
Tue Aug  2 21:55:21 2011
@@ -28,6 +28,10 @@ import org.apache.tuscany.sca.provider.S
 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;

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java?rev=1153285&r1=1153284&r2=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/local/XMLWFLocalSCAReferenceBindingProvider.java
Tue Aug  2 21:55:21 2011
@@ -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 XMLWFLocalSCAReferenceBindi
         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);                
     }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java?rev=1153285&r1=1153284&r2=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java
Tue Aug  2 21:55:21 2011
@@ -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);

Copied: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java
(from r1153160, tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java?p2=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java&p1=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java&r1=1153160&r2=1153285&rev=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java
Tue Aug  2 21:55:21 2011
@@ -23,16 +23,20 @@ import org.apache.tuscany.sca.databindin
 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

Copied: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java
(from r1153160, tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java?p2=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java&p1=tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java&r1=1153160&r2=1153285&rev=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java
Tue Aug  2 21:55:21 2011
@@ -26,18 +26,22 @@ import org.apache.tuscany.sca.databindin
 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

Modified: tuscany/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java?rev=1153285&r1=1153284&r2=1153285&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
Tue Aug  2 21:55:21 2011
@@ -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 DataBindingRuntimeWireProce
         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 DataBindingRuntimeWireProce
         }
         
     }
+    
+
+    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);
+    }
 
 }

Added: tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java?rev=1153285&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
(added)
+++ tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java
Tue Aug  2 21:55:21 2011
@@ -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;
+    }
+}
+



Mime
View raw message