diff options
author | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-02 21:55:21 +0000 |
---|---|---|
committer | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-02 21:55:21 +0000 |
commit | 024cdd6f7359eaa15f960b345bc24ed0a6de4fdf (patch) | |
tree | 97c2701c65718442d40b4f8a5e62eb752138f253 /sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire | |
parent | ec27c0bcaba50691c0f0271dab7fe14e31696d83 (diff) |
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.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1153285 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire')
-rw-r--r-- | sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java | 96 |
1 files changed, 15 insertions, 81 deletions
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); + } } |