users@jersey.java.net

Re: [Jersey] JSONP Callback support

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Wed, 04 Feb 2009 11:34:23 -0500

Farrukh Najmi wrote:
> Jakub Podlesak wrote:
>> On Wed, Feb 04, 2009 at 11:30:21AM +0100, Paul Sandoz wrote:
>>
>> <snip/>
>>
>>>> The use of '@' sign in resulting JSON as described by BadgerFish is
>>>> causing a downstream problem for me as the toolkit I am using to
>>>> process JSON does not like it. So I need to fix my ResponseFilter
>>>> to remove '@' sign in the JSON output.
>>
>> You do not need to filter '@' out using ResponseFilter,
>> please see [1] for two options how to get rid of '@' and still
>> retain possibility to de-serialize the JSON back to Java.
>
> I created a class as follows using NATURAL notation and am using
> latest svn bit for 1.0.2-SNAPSHOT.
> I am still getting getting '@' chars in field names. Do I need to do
> something else in terms of configuration
> to tell jersey runtime to use this Provider (I am guessing that is
> what @Provider annotation is already doing).
>
> Any idea what I could be missing?
>
> Note I am using a contextPath rather than specific classes which is
> morer tedious to do.
>
>
> @Provider
> public final class JAXBContextResolver implements
> ContextResolver<JAXBContext> {
>
> private final JAXBContext context;
>
> public JAXBContextResolver() throws Exception {
> this.context = new JSONJAXBContext(
> JSONConfiguration.getBuilder(JSONConfiguration.Notation.NATURAL).build(),
> BindingUtility.jaxbContextPath);
> }
>
> public JAXBContext getContext(Class<?> objectType) {
> return context;
> }
> }
>
>
> Thanks very much for all you help.
>
Paul pointed out the problem is because I use spring to configure jersey
components therefor

<paul>
Because you are using Spring then by default Jersey will let Spring
define the components and it will not search by default.
If you want to intermix Spring and non Spring-components you need to
configure Jersey to scan. Use the package config
init-param for that

See:
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.1/api/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/package-summary.html
</paul>

Thanks Paul! I am trying this out.

-- 
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com