context resolver with package names ?

From: Felipe Gaścho <>
Date: Sat, 20 Feb 2010 16:28:58 +0100

I tried to implement the context resolver using package names instead
of class names, but it didn't worked. The JSON representation still
with the JAXB format (with @ as attributes prefix)..

* the same class using specific classes works, but I have hundreds of
classes and it is boring to maintain the list

public class MyJAXBContextResolver implements ContextResolver<JAXBContext> {

        private JAXBContext context;
        private final static String PACKAGE = PujAdvertisementEntity.class

        public MyJAXBContextResolver() throws Exception {
                this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),

        public JAXBContext getContext(Class<?> objectType) {
                return (PACKAGE.equals(objectType.getPackage().getName())) ? context
                                : null;