From 024cdd6f7359eaa15f960b345bc24ed0a6de4fdf Mon Sep 17 00:00:00 2001 From: scottkurz Date: Tue, 2 Aug 2011 21:55:21 +0000 Subject: 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 --- .../DefaultLocalSCAReferenceBindingProvider.java | 26 ++++++-- .../local/XMLWFLocalSCABindingProviderFactory.java | 4 ++ .../XMLWFLocalSCAReferenceBindingProvider.java | 14 ++-- .../sca/transform/BindingSCATransformer.java | 4 ++ .../transform/DefaultBindingSCATransformer.java | 54 --------------- .../sca/transform/SameDBCopyTransformer.java | 58 ++++++++++++++++ .../sca/transform/WSDLMediateTransformer.java | 78 ++++++++++++++++++++++ .../sca/transform/XMLWFBindingSCATransformer.java | 74 -------------------- 8 files changed, 174 insertions(+), 138 deletions(-) delete mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java create mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java create mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java delete mode 100644 sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java (limited to 'sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org') 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 { 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/DefaultBindingSCATransformer.java deleted file mode 100644 index 77e93f8672..0000000000 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java +++ /dev/null @@ -1,54 +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.binding.sca.transform; - -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 { - - private Mediator mediator; - private Operation sourceOperation; - private Operation targetOperation; - - public DefaultBindingSCATransformer(Mediator mediator, Operation sourceOperation, InvocationChain chain) { - this.mediator = mediator; - this.sourceOperation = sourceOperation; - this.targetOperation = chain.getTargetOperation(); - } - - @Override - public Object transformInput(Object body) { - return mediator.copyInput(body, sourceOperation, targetOperation); - } - - @Override - public Object transformOutput(Object body) { - return mediator.copyOutput(body, sourceOperation, targetOperation); - } - - @Override - public Object transformFault(Object body) { - return mediator.copyFault(body, sourceOperation, targetOperation); - } - -} - diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java new file mode 100644 index 0000000000..c4fc9b94a2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/SameDBCopyTransformer.java @@ -0,0 +1,58 @@ +/* + * 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.binding.sca.transform; + +import org.apache.tuscany.sca.databinding.Mediator; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; + +/** +* +* @version $Rev$ $Date$ +*/ +public class SameDBCopyTransformer implements BindingSCATransformer { + + private Mediator mediator; + private Operation sourceOperation; + private Operation targetOperation; + + public SameDBCopyTransformer(Mediator mediator, Operation sourceOperation, Operation targetOperation) { + this.mediator = mediator; + this.sourceOperation = sourceOperation; + this.targetOperation = targetOperation; + } + + @Override + public Object transformInput(Object body) { + return mediator.copyInput(body, sourceOperation, targetOperation); + } + + @Override + public Object transformOutput(Object body) { + return mediator.copyOutput(body, sourceOperation, targetOperation); + } + + @Override + public Object transformFault(Object body) { + return mediator.copyFault(body, sourceOperation, targetOperation); + } + +} + diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java new file mode 100644 index 0000000000..7e36442d4e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/WSDLMediateTransformer.java @@ -0,0 +1,78 @@ +/* + * 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.binding.sca.transform; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.databinding.Mediator; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; + +/** +* +* @version $Rev$ $Date$ +*/ +public class WSDLMediateTransformer implements BindingSCATransformer { + + private Mediator mediator; + private Operation sourceOperation; + private Operation wsdlBindingOperation; + private Operation targetOperation; + + public WSDLMediateTransformer(Mediator mediator, Operation sourceOperation, Operation wsdlBindingOperation, Operation targetOperation) { + this.mediator = mediator; + this.sourceOperation = sourceOperation; + this.wsdlBindingOperation = wsdlBindingOperation; + this.targetOperation = targetOperation; + } + + @Override + public Object transformInput(Object body) { + Map map1 = new HashMap(); + Object intermediate = mediator.mediateInput(body, sourceOperation, wsdlBindingOperation, map1); + Map map2 = new HashMap(); + Object result = mediator.mediateInput(intermediate, wsdlBindingOperation, targetOperation, map2); + return result; + } + + @Override + public Object transformOutput(Object body) { + Map map1 = new HashMap(); + Object intermediate = mediator.mediateOutput(body, wsdlBindingOperation, targetOperation, map1); + Map map2 = new HashMap(); + Object result = mediator.mediateOutput(intermediate, sourceOperation, wsdlBindingOperation, map2); + + return result; + + } + + @Override + public Object transformFault(Object body) { + Map map1 = new HashMap(); + Object intermediate = mediator.mediateFault(body, wsdlBindingOperation, targetOperation, map1); + Map map2 = new HashMap(); + Object result = mediator.mediateFault(intermediate, sourceOperation, wsdlBindingOperation, map2); + return result; + + } + +} + 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/XMLWFBindingSCATransformer.java deleted file mode 100644 index cc366c1f7a..0000000000 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java +++ /dev/null @@ -1,74 +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.binding.sca.transform; - -import java.util.HashMap; -import java.util.Map; - -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 { - - private Mediator mediator; - private Operation sourceOperation; - private Operation wsdlBindingOperation; - private Operation targetOperation; - - public XMLWFBindingSCATransformer(Mediator mediator, Operation sourceOperation, Operation wsdlBindingOperation, InvocationChain chain) { - this.mediator = mediator; - this.sourceOperation = sourceOperation; - this.wsdlBindingOperation = wsdlBindingOperation; - this.targetOperation = chain.getTargetOperation(); - } - - @Override - public Object transformInput(Object body) { - Map map1 = new HashMap(); - Object intermediate = mediator.mediateInput(body, sourceOperation, wsdlBindingOperation, map1); - Map map2 = new HashMap(); - Object result = mediator.mediateInput(intermediate, wsdlBindingOperation, targetOperation, map2); - return result; - } - - @Override - public Object transformOutput(Object body) { - Map map1 = new HashMap(); - Object intermediate = mediator.mediateOutput(body, wsdlBindingOperation, targetOperation, map1); - Map map2 = new HashMap(); - Object result = mediator.mediateOutput(intermediate, sourceOperation, wsdlBindingOperation, map2); - - return result; - - } - - @Override - public Object transformFault(Object body) { - Map map1 = new HashMap(); - Object intermediate = mediator.mediateFault(body, wsdlBindingOperation, targetOperation, map1); - Map map2 = new HashMap(); - Object result = mediator.mediateFault(intermediate, sourceOperation, wsdlBindingOperation, map2); - return result; - - } - -} - -- cgit v1.2.3