Hi,
I also added a test case [1][2] to try round trips between POJO and JSON
using com/metaparadigm/json-rpc/1.0/json-rpc-1.0.jar. The result is pretty
much positive. It can work with simple types, collections, arrays and
objects.
Here is a sample result:
{"notes":{"list":["1","2"],"javaClass":"java.util.ArrayList"},"good":false,"rates":[1,2],"service":{"javaClass":"org.apache.tuscany.sca.databinding.json.MyInterfaceImpl","id":"ID001"},"map":{"map":{"1":1},"javaClass":"java.util.HashMap"},"javaClass":"org.apache.tuscany.sca.databinding.json.MyBean","name":"Test","age":20,"otherService":{"javaClass":"org.apache.tuscany.sca.databinding.json.MyInterfaceImpl","id":"ID001"}}
As you can see, I have to enable a flag in the serializer to produce the
"javaClass" hints so that the deserializer can work with interfaces such as
List, Map and MyInterface.
The Map structure is different than we see with JAXB. But it seems to be
reasonable for JavaScripts.
[1] http://svn.apache.org/viewvc?rev=601958&view=rev
[2]
https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java
Thanks,
Raymond
----- Original Message -----
From: "Jean-Sebastien Delfino" <[EMAIL PROTECTED]>
To: <tuscany-dev@ws.apache.org>
Sent: Wednesday, December 05, 2007 5:45 PM
Subject: Re: Data transformation from/to POJO
Raymond Feng wrote:
Hi,
I have checked in the first cut under
http://svn.apache.org/viewvc?rev=601501&view=rev. With these changes, we
now use JAXB databinding to deal with POJOs (including simple and complex
types). By the JAXB Java to XML default mapping, POJOs are supported in
line with the JavaBeans patterns with the flowing rules.
1) There is a protected or public no-arg constructor
2) A property is either a public field or public setter & getter. Even
for Collection type, the setter is required.
3) The property can not be an interface
4) Circular object reference is not supported
5) References to the same object are flattened
One caveat is that it brings the jaxb-api and jaxb-impl as core
dependencies (about 1MB). We could try to implement the default Java/XML
mapping by ourselves if that's desirable.
There are also other things we need to improve, for example, how to
render a JAXB object as XMLStreamReader. The quick and dirty way is to
marshal the JAXB object into a byte array and create XMLStreamReader out
of it. We could even use the fast-infoset to help the performance of the
round trip.
Thanks,
Raymond
Great Thanks!
Now that we have the external behavior right I should be able to clean up
the store scenario.
+1 for improving and optimizing the implementation over time.
If anybody is interested it would be nice to get concrete performance
numbers at some point, analyze the numbers and define performance
objectives. This should help understand what needs to be optimized.
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]