cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tong, Gary \(IDEAS\)" <Gary.T...@morganstanley.com>
Subject RE: JSON in CXF
Date Tue, 07 Apr 2009 15:00:17 GMT
I think the scope is the same, but the list of features could vary greatly.

The full list of (possibly too many) features is:

1) Reflection caching - Similar to JAXB, the library would reflect over the bound classes
at initialization and store the structures internally for faster marshalling/unmarshalling
later.
2) Marshalling of a java bean to a JSON object.
3) Unmarshalling of a java bean from a JSON object.
4) Ability to dynamically update the reflection cache when new classes are found (unlike JAXB
with its @XmlSeeAlso)
5) A JSON equivalent for XmlJavaTypeAdapter
6) Inheritance

Also some nice-to-haves:
6) Pluggable annotation reader that allows people to choose between using the custom CXF annotations
or mapping JAXB ones.  (Interesting sidenote for this.  Adding this would allow for XML-based
annotation as well)
7) CGLib-based reflection optimization.

+unit tests for everything.

Not sure how much code can be expected from a GSoC student.

Cheers,
Gary

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com]
Sent: 07 April 2009 14:49
To: dev@cxf.apache.org
Subject: Re: JSON in CXF

Hi

I'm not actually sure. What would be the scope of such a project ? My understanding is that
at the moment we'd like to enhance the existing JSON provider for it to become aware of JSON
annotations (which will be specific to CXF), such that JSONObject/etc code bundled into Jettison
gets actually utilized...

If yes - then I'm not sure it would qualify ? Would you define the scope differently ?
cheers, Sergey

----- Original Message -----
From: "Tong, Gary (IDEAS)" <Gary.Tong@morganstanley.com>
To: <dev@cxf.apache.org>
Sent: Tuesday, April 07, 2009 2:21 PM
Subject: RE: JSON in CXF


Would you want to give this to someone from GSoC?  This could actually be a pretty sweet project.

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com]
Sent: 07 April 2009 12:14
To: dev@cxf.apache.org
Subject: Re: JSON in CXF

Hi Gary

> If you give me until next week I should be able to package something together and send
it to you.
it would be super, take your time please...

> Rewriting Sun libraries?  Working with JSON?  Hells yeah.

that's the right attitude :-).

cheers, Sergey

----- Original Message -----
From: "Tong, Gary (IDEAS)" <Gary.Tong@morganstanley.com>
To: <dev@cxf.apache.org>
Sent: Tuesday, April 07, 2009 8:53 AM
Subject: RE: JSON in CXF


Hi Sergey,

If you give me until next week I should be able to package something together and send it
to you.

Alternatively, this would be a great project for GSoC, if it's not too late to submit projects.
 Rewriting Sun libraries?  Working with JSON?  Hells yeah.

Cheers,
Gary

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com]
Sent: 06 April 2009 12:01
To: dev@cxf.apache.org
Subject: Re: JSON in CXF

Hi Gary
>>
>> I ended up writing my own converter for JSON that uses its own
>> annotations seperate from JAXB.  It's a pretty quick implementation,
>> and only does what I need it to do.  It depends on the JSON objects
>> from json.org, which are also included in Jettison under a different
>> package.  The annotations can be used alongside JAXB like so:
>>
>> @XmlRootElement(name = "response")
>> @JsonObject
>> public class MyResponse {
>>  @XmlAttribute
>>  @JsonField
>>  private boolean success;
>>  @XmlElement(name = "msg")
>>  @JsonField(name = "msg")
>>  private String message;
>>  @XmlElementWrapper(name = "errors")
>>  @XmlElement(name = "error")
>>  @JsonField(name = "errors", required = true)  private List<String>
>> errors;  ...
>> }

Would you be interested in updating the existing CXF JSONProvider (the one based on Jettison)
for it to support @JsonObject/etc annotations ? I was about to do it myself but given my JSON
experience (not great so to say) I thought I would ping you first :-) we can introduce a new
package, org.apache.cxf.jaxrs.providers.json, or org.apache.cxf.jaxrs.ext.json, and add these
annotations there, and then rely on the fact Jettison ships JSonObject/etc...

cheers, Sergey

>>
>> This will produce this JSON:
>>
>> {success: true, msg: "Test Message", errors: ["a", "b"]}
>>
>> And this XML:
>>
>> <response success="true"><msg>Test
>> Message</msg><errors><error>a</error><error>b</error></errors></respo
>> nse>
>>
>> Since this was written only for personal use, it's a fair bit aways
>> from being a full-featured library.  Stuff that needs to be done
>> before public
>> consumption:
>>
>> 1) Two-way serialization.  Currently it's only bean -> JSON but not
>> the other way around.
>> 2) Reflection caching.  Currently all reflection happens in the
>> middle of serialization.  Breaking it up into reflection +
>> serialization phases as JAXB does it would speed things up considerably.
>> 3) Ability to switch between field/method accessors (currently it
>> only reads
>> fields)
>>
>> As well as some features that could be really useful such as:
>>
>> 1) Pluggable annotation adapters that can be used to read directly
>> from JAXB annotations
>> 2) Type adapters that will allow custom marshalling/unmarshalling,
>> although this could also be done via getters/setters
>>
>> What's the interest level in putting something like this into CXF?
>>
>> Cheers,
>> Gary
>>


--------------------------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.


--------------------------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.


--------------------------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.

Mime
View raw message