You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Simon Laws (JIRA)" <de...@tuscany.apache.org> on 2011/08/22 10:39:29 UTC

[jira] [Updated] (TUSCANY-3696) JSONP binding doesn't work with arrays

     [ https://issues.apache.org/jira/browse/TUSCANY-3696?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simon Laws updated TUSCANY-3696:
--------------------------------

    Fix Version/s: Java-SCA-2.x

> JSONP binding doesn't work with arrays
> --------------------------------------
>
>                 Key: TUSCANY-3696
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-3696
>             Project: Tuscany
>          Issue Type: Bug
>    Affects Versions: Java-SCA-1.4, Java-SCA-1.6, Java-SCA-2.0-M5
>         Environment: All
>            Reporter: Simon Laws
>             Fix For: Java-SCA-2.x
>
>
> The JSONP binding doesn't apply the JSON conversion correctly when an operation parameter is of array type. This is because the data type model is set incorrectly in the array case. 
> Both service and reference providers for the JSONP binding reset the binding interface contract databinding in order to enable JSON conversion using the JSON databinding using a line like....
> contract.getInterface().resetDataBinding("JSON2x");
> This works fine for ordinary parameters. What I didn't realize when I added this was that arrays are treated specially for some reason. There's code in InterfaceImpl which reads...
>     private void setDataBinding(DataType dataType, String dataBinding) {
>         if ("java:array".equals(dataType.getDataBinding())) {
>             setDataBinding((DataType)dataType.getLogical(), dataBinding);
>         } else {
>             dataType.setDataBinding(dataBinding);
>         }
>     }
> When you then reset a databinding on an operation that has a parameter of an array type you get something like....
> Contract
>    Interface 
>        Operation
>             InputDataType
>                   Logical  - databinding = java:array
>                         Logical - databinding = JSON2x
> This lead to the databinding code using the following transformations
> Input2InputTransformer
>    Array2ArrayTransformer  
>          Object2JSONTransformer
> Where I would have expected 
> Contract
>    Interface 
>        Operation
>             InputDataType
>                   Logical  - databinding = JSON2x
>                         Logical - databinding = JSON2x
> Input2InputTransformer 
>      Object2JSONTransformer
> I don't know what the advantage of keeping the array databinding in place. I guess the point is that the databinding code may not be able to cope with array transfomation but it can in the JSON case. So I need to extend the databinding resetting code to read...
>         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");
>     		}
>         }
> I may of course be missing something obvious to those who know about databinding. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira