Return-Path: Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: (qmail 15356 invoked from network); 7 Apr 2009 15:00:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Apr 2009 15:00:58 -0000 Received: (qmail 30440 invoked by uid 500); 7 Apr 2009 15:00:57 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 30356 invoked by uid 500); 7 Apr 2009 15:00:57 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 30346 invoked by uid 99); 7 Apr 2009 15:00:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 15:00:57 +0000 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Gary.Tong@morganstanley.com designates 205.228.53.68 as permitted sender) Received: from [205.228.53.68] (HELO hqmtaint01.ms.com) (205.228.53.68) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 15:00:48 +0000 Received: from hqmtaint01 (localhost.ms.com [127.0.0.1]) by hqmtaint01.ms.com (output Postfix) with ESMTP id A201C88C53F for ; Tue, 7 Apr 2009 11:00:26 -0400 (EDT) Received: from ny0032as02 (unknown [170.74.93.69]) by hqmtaint01.ms.com (internal Postfix) with ESMTP id 84F08B00032 for ; Tue, 7 Apr 2009 11:00:26 -0400 (EDT) Received: from ny0032as02 (localhost [127.0.0.1]) by ny0032as02 (msa-out Postfix) with ESMTP id 123EAD3C302 for ; Tue, 7 Apr 2009 11:00:26 -0400 (EDT) Received: from PIWEXOB02.msad.ms.com (piwexob02 [205.228.46.104]) by ny0032as02 (mta-in Postfix) with ESMTP id 0FBC064C037 for ; Tue, 7 Apr 2009 11:00:26 -0400 (EDT) Received: from hnwexhub05.msad.ms.com ([10.184.121.119]) by PIWEXOB02.msad.ms.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 7 Apr 2009 11:00:24 -0400 Received: from OYWEXHUB01.msad.ms.com (10.174.153.24) by hnwexhub05.msad.ms.com (10.184.121.119) with Microsoft SMTP Server (TLS) id 8.1.336.0; Tue, 7 Apr 2009 11:00:22 -0400 Received: from LNWEXMBX0142.msad.ms.com ([10.174.156.76]) by OYWEXHUB01.msad.ms.com ([10.174.153.24]) with mapi; Tue, 7 Apr 2009 16:00:17 +0100 From: "Tong, Gary \(IDEAS\)" To: Date: Tue, 7 Apr 2009 16:00:17 +0100 Content-Class: urn:content-classes:message Importance: normal Priority: normal x-mimeole: Produced By Microsoft MimeOLE V6.00.3790.4325 Subject: RE: JSON in CXF Thread-Topic: JSON in CXF Thread-Index: Acm3h8XeuT0ZfnoQRN6JTjbVuocAhQABsflQ Message-ID: References: <177738ce0902251647n78b0bcaar236e3b903b37fc8b@mail.gmail.com> <028d01c99834$0d67fd50$0c02050a@emea.progress.com> <024e01c9b6a7$090ab4a0$0c02050a@emea.progress.com> <011a01c9b771$f4c52cc0$0c02050a@emea.progress.com> <017501c9b787$9f9ffca0$0c02050a@emea.progress.com> In-Reply-To: <017501c9b787$9f9ffca0$0c02050a@emea.progress.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 07 Apr 2009 15:00:24.0717 (UTC) FILETIME=[948CDBD0:01C9B791] X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.35/RELEASE, bases: 07042009 #1826998, status: clean X-Virus-Checked: Checked by ClamAV on apache.org 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)" To: 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)" To: 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 =3D "response") >> @JsonObject >> public class MyResponse { >> @XmlAttribute >> @JsonField >> private boolean success; >> @XmlElement(name =3D "msg") >> @JsonField(name =3D "msg") >> private String message; >> @XmlElementWrapper(name =3D "errors") >> @XmlElement(name =3D "error") >> @JsonField(name =3D "errors", required =3D true) private = List >> 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: >> >> Test >> Messageab> 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.