Hi,
I have some problems when using my own @Provider. I'm using Jackson for
JSON processing and all works well but I can't figure out, how to modify
the jackson content provider.
I registered my own provider as shown in documentation
(
https://jersey.java.net/documentation/latest/media.html#json.jackson)
but the output does not change.
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JsonProvider implements ContextResolver<ObjectMapper>{
final ObjectMapper om;
public JsonProvider() {
om = new ObjectMapper();
om.enable(SerializationFeature.INDENT_OUTPUT);
}
@Override
public ObjectMapper getContext(Class<?> type) {
return om;
}
}
@ApplicationPath("/")
public class App extends ResourceConfig {
public SmartCampusServer() {
packages("package");
register(JsonProvider.class);
register(JacksonFeature.class);
}
}
I'm using recent stable versions of jackson and jersey.
Full Code is available as maven project on github
https://github.com/ne0h/proseminar2013/tree/jsonprovider/server/Java/SmartCampusServer/
Simon Herter