A JAXBContextResolver I created is not being used, and my Resources are
producing JSON output which looks like "mapped" builder rather than from the
"natural" builder I expect. There are no errors at runtime.
How should my JAXBContextResolver be found by Jersey? It seems I have not
configured something correctly, as it is never instantiated, nor is
getContext() invoked.
Is there something special I need to do in spring or jersey to get this
@Provider recognized?
I am using jersey-1.0.2 with spring-2.5.6 (and tried with jersey-1.0.3 with
the same results).
@Provider
public final class JAXBContextResolver implements
ContextResolver<JAXBContext> {
private final JAXBContext context;
private final Set<Class<?>> types;
private final Class<?>[] cTypes = { MyClass.class }
public JAXBContextResolver() throws Exception {
// logging shows this is never executed
this.types = new HashSet<Class<?>>(Arrays.asList(cTypes));
this.context = new
JSONJAXBContext(JSONConfiguration.natural().build(), cTypes);
}
public JAXBContext getContext(Class<?> objectType) {
// logging shows this is never executed
return (types.contains(objectType)) ? context : null;
}
}
...Chad