public JacksonJaxbJsonProvider buildJacksonJaxbJsonProvider() { ObjectMapper mapper = new ObjectMapper(); // mapper.enable(SerializationFeature.INDENT_OUTPUT); AnnotationIntrospector pair = AnnotationIntrospector.pair( new PrioritizeJSONPropertyJaxbAnnotationIntrospector(), new JacksonAnnotationIntrospector()); mapper.getDeserializationConfig().with(pair); mapper.getSerializationConfig().with(pair); mapper.setAnnotationIntrospectors(pair, pair); // create JsonProvider to provide custom ObjectMapper ResteasyJackson2Provider provider = new ResteasyJackson2Provider(); provider.setMapper(mapper); return provider; }
public static ObjectMapper setupInjectablesInObjectMapper(ObjectMapper objectMapper) { objectMapper.registerModule( new SimpleModule("testModule").registerSubtypes(LocalLoadSpec.class)); final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector(); objectMapper.setAnnotationIntrospectors( new AnnotationIntrospectorPair( guiceIntrospector, objectMapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair( guiceIntrospector, objectMapper.getDeserializationConfig().getAnnotationIntrospector())); objectMapper.setInjectableValues( new GuiceInjectableValues( GuiceInjectors.makeStartupInjectorWithModules( ImmutableList.of( new Module() { @Override public void configure(Binder binder) { binder.bind(LocalDataSegmentPuller.class); } })))); return objectMapper; }