diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-29 09:23:57 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-29 09:23:57 +0000 |
commit | 5055f20ec42ce04534f6eb1d151a92a8f757e8ef (patch) | |
tree | 94e015eabc4f0aeaf095ed26659d281bcb496bc0 /sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java | |
parent | 76598f25fab0e1f07759dd484ebf043a331b3856 (diff) |
TUSCANY-3696 - Support parameter of type array in the JSONP binding.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1002534 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 35 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java index d68a353896..3fe293cb8d 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java @@ -19,7 +19,10 @@ package org.apache.tuscany.sca.binding.jsonp.runtime;
+import java.util.List;
+
import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -44,7 +47,22 @@ public class JSONPReferenceBindingProvider implements ReferenceBindingProvider { } catch (Exception ex){
// we know this supports clone
}
+
contract.getInterface().resetDataBinding("JSON2x");
+
+ // force array types to map to JSON also
+ for (Operation operation : contract.getInterface().getOperations()){
+ DataType<List<DataType>> inputTypes = operation.getInputType();
+ for (DataType inputType : inputTypes.getLogical()){
+ if ("java:array".equals(inputType.getDataBinding())){
+ inputType.setDataBinding("JSON2x");
+ }
+ }
+ DataType outputType = operation.getOutputType();
+ if ("java:array".equals(outputType.getDataBinding())){
+ outputType.setDataBinding("JSON2x");
+ }
+ }
}
public Invoker createInvoker(Operation operation) {
return new JSONPInvoker(operation, binding);
diff --git a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java index 28a809f989..a76df37522 100644 --- a/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java +++ b/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java @@ -19,9 +19,12 @@ package org.apache.tuscany.sca.binding.jsonp.runtime;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -53,6 +56,20 @@ public class JSONPServiceBindingProvider implements ServiceBindingProvider { // we know this supports clone
}
contract.getInterface().resetDataBinding("JSON2x");
+
+ // force array types to map to JSON also
+ for (Operation operation : contract.getInterface().getOperations()){
+ DataType<List<DataType>> inputTypes = operation.getInputType();
+ for (DataType inputType : inputTypes.getLogical()){
+ if ("java:array".equals(inputType.getDataBinding())){
+ inputType.setDataBinding("JSON2x");
+ }
+ }
+ DataType outputType = operation.getOutputType();
+ if ("java:array".equals(outputType.getDataBinding())){
+ outputType.setDataBinding("JSON2x");
+ }
+ }
}
public void start() {
|