diff options
author | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-27 21:20:22 +0000 |
---|---|---|
committer | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-07-27 21:20:22 +0000 |
commit | c1061930d07751d489c86812b4f11bfbe789ed96 (patch) | |
tree | 2c57fbceecec77c697c1900a18c2b3b8153b6eca /sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca | |
parent | 00abc80dcd81d642fd5d3473ea0f536f05aa53d9 (diff) |
TUSCANY-3894. Refactor local sca binding so that the exact details of the data copy can be plugged in via the BindingProviderFactory extension point, while keeping a core, base portion of the binding to do things like calculate whether to do the pass-by-reference optimization and establish other aspects of the invoker/interceptor chain. The data handling is factored into a BindingSCATransformer class. The default impl will continue to use MediatorImpl.copyXXX methods, and will use Java-serialization first then XML/JAXB-serialization. The second impl included uses XML serialization and calculates a WSDL interfaceContract.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1151632 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca')
4 files changed, 157 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java index 2cc71f1744..5b47443df8 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/DelegatingSCAReferenceBindingProvider.java @@ -20,7 +20,7 @@ package org.apache.tuscany.sca.binding.sca.provider; import org.apache.tuscany.sca.assembly.SCABinding; -import org.apache.tuscany.sca.binding.local.LocalSCAReferenceBindingProvider; +import org.apache.tuscany.sca.binding.local.DefaultLocalSCAReferenceBindingProvider; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; @@ -47,8 +47,8 @@ public class DelegatingSCAReferenceBindingProvider implements EndpointReferenceA // reset the EPR to binding.sca EPR because the local optimization assumes // this to be the case. - if (provider instanceof LocalSCAReferenceBindingProvider){ - ((LocalSCAReferenceBindingProvider)provider).setEndpointReference(endpointReference); + if (provider instanceof DefaultLocalSCAReferenceBindingProvider){ + ((DefaultLocalSCAReferenceBindingProvider)provider).setEndpointReference(endpointReference); } } } 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 new file mode 100644 index 0000000000..e84668fb1d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/BindingSCATransformer.java @@ -0,0 +1,26 @@ +/*
+ * 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;
+
+public interface BindingSCATransformer {
+ Object transformInput(Object body);
+ Object transformOutput(Object body);
+ Object transformFault(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 new file mode 100644 index 0000000000..77e93f8672 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/DefaultBindingSCATransformer.java @@ -0,0 +1,54 @@ +/*
+ * 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/XMLWFBindingSCATransformer.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java new file mode 100644 index 0000000000..cc366c1f7a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/transform/XMLWFBindingSCATransformer.java @@ -0,0 +1,74 @@ +/*
+ * 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<String, Object> map1 = new HashMap<String, Object>();
+ Object intermediate = mediator.mediateInput(body, sourceOperation, wsdlBindingOperation, map1);
+ Map<String, Object> map2 = new HashMap<String, Object>();
+ Object result = mediator.mediateInput(intermediate, wsdlBindingOperation, targetOperation, map2);
+ return result;
+ }
+
+ @Override
+ public Object transformOutput(Object body) {
+ Map<String, Object> map1 = new HashMap<String, Object>();
+ Object intermediate = mediator.mediateOutput(body, wsdlBindingOperation, targetOperation, map1);
+ Map<String, Object> map2 = new HashMap<String, Object>();
+ Object result = mediator.mediateOutput(intermediate, sourceOperation, wsdlBindingOperation, map2);
+
+ return result;
+
+ }
+
+ @Override
+ public Object transformFault(Object body) {
+ Map<String, Object> map1 = new HashMap<String, Object>();
+ Object intermediate = mediator.mediateFault(body, wsdlBindingOperation, targetOperation, map1);
+ Map<String, Object> map2 = new HashMap<String, Object>();
+ Object result = mediator.mediateFault(intermediate, sourceOperation, wsdlBindingOperation, map2);
+ return result;
+
+ }
+
+}
+
|