diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 11:30:41 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-08 11:30:41 +0000 |
commit | 86f8397dbc7f8c5da94ef4f06019420953100c5c (patch) | |
tree | 4a0f5a5aeca89fd768cbd1f70939d0606e510d96 /sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc | |
parent | 5a7306e0e7873abb952cf38ef4f6bb93d5e6409a (diff) |
TUSCANY-3668 - support BigDecimal in JSON format and JSONRPC binding. BigDecimal is detected in an interface as a Java simple type but you have to manage it explicitly when converting from primitive types.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@994995 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc')
2 files changed, 8 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java index 3cdcb32830..f9b37f30b2 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.binding.jsonrpc.provider; +import java.math.BigDecimal; import java.util.List; import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding; @@ -45,14 +46,16 @@ public class JSONRPCDatabindingHelper { if (inputType != null) { List<DataType> logical = inputType.getLogical(); for (DataType inArg : logical) { - if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) { + if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding()) || + inArg.getPhysical() == BigDecimal.class) { inArg.setDataBinding(JSONDataBinding.NAME); } } } DataType outputType = operation.getOutputType(); if (outputType != null) { - if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) { + if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding()) || + outputType.getPhysical() == BigDecimal.class ) { outputType.setDataBinding(JSONDataBinding.NAME); } } diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java index 10e9368936..39881ce68d 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding; +import org.apache.tuscany.sca.databinding.json.JSONDataBinding; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -80,7 +81,8 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { public void start() { // Set default databinding to json - // serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); + // replaced by JSONRPCDatabindingHelper.setDataBinding(serviceContract.getInterface()); above + //serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); // Determine the service business interface Class<?> serviceInterface = getTargetJavaClass(serviceContract.getInterface()); |