users@jersey.java.net

[Jersey] Not able to customize the JSON encoding ....

From: <brian_at_gabey.com>
Date: Thu, 28 Mar 2013 21:11:24 +0000 (GMT)

I followed the example in the users guide for adding a ContextResolver
so I can pick the JSON encoding style.
The getContext method is never called on my class.
It is in the package with the Path Endpoints (Which are picked up
fine).
I am very confused and any help would be nice.

Thanks,
Brian
Example code
public class JAXBContextResolver implements
ContextResolver<JAXBContext> {

    private JAXBContext context;
    private Set<Class> types;
    private Class[] clss =
{StorageSystemListResponse.class,StorageSystemResponse.class};

    public JAXBContextResolver() throws Exception {
        types=new HashSet<>(Arrays.asList(clss));
        System.out.println("************************** IN JAXB
1**************************************");
        System.err.println("************************** IN JAXB
1**************************************");
        this.context = new
JSONJAXBContext(JSONConfiguration.badgerFish().build(),clss);
     }
     public JAXBContext getContext(Class<?> objectType) {
        System.out.println("************************** IN JAXB
2**************************************");
        System.err.println("************************** IN JAXB
2**************************************");
         
         return (types.contains(objectType)) ? context : null;
     }
}