Search in sources :

Example 1 with AnnotationIntrospectorPair

use of com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair in project druid by druid-io.

the class DruidSecondaryModule method setupJackson.

private void setupJackson(Injector injector, final ObjectMapper mapper) {
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setInjectableValues(new GuiceInjectableValues(injector));
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair)

Example 2 with AnnotationIntrospectorPair

use of com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair in project druid by druid-io.

the class URIExtractionNamespaceTest method registerTypes.

public static ObjectMapper registerTypes(final ObjectMapper mapper) {
    mapper.setInjectableValues(new GuiceInjectableValues(Guice.createInjector(ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(ObjectMapper.class).annotatedWith(Json.class).toInstance(mapper);
            binder.bind(ObjectMapper.class).toInstance(mapper);
        }
    })))).registerSubtypes(URIExtractionNamespace.class, URIExtractionNamespace.FlatDataParser.class);
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
    return mapper;
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Module(com.google.inject.Module) GuiceAnnotationIntrospector(io.druid.guice.GuiceAnnotationIntrospector) GuiceInjectableValues(io.druid.guice.GuiceInjectableValues) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper)

Example 3 with AnnotationIntrospectorPair

use of com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair in project druid by druid-io.

the class LoadSpecTest method setUp.

@BeforeClass
public static void setUp() {
    final Injector injector = GuiceInjectors.makeStartupInjectorWithModules(ImmutableList.of(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(LocalDataSegmentPuller.class);
        }
    }));
    mapper = new DefaultObjectMapper();
    mapper.registerModule(new SimpleModule("loadSpecTest").registerSubtypes(LocalLoadSpec.class));
    mapper.setInjectableValues(new GuiceInjectableValues(injector));
    final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector();
    mapper.setAnnotationIntrospectors(new AnnotationIntrospectorPair(guiceIntrospector, mapper.getSerializationConfig().getAnnotationIntrospector()), new AnnotationIntrospectorPair(guiceIntrospector, mapper.getDeserializationConfig().getAnnotationIntrospector()));
}
Also used : AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceAnnotationIntrospector(io.druid.guice.GuiceAnnotationIntrospector) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceInjectableValues(io.druid.guice.GuiceInjectableValues) BeforeClass(org.junit.BeforeClass)

Example 4 with AnnotationIntrospectorPair

use of com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair in project druid by druid-io.

the class IngestSegmentFirehoseFactoryTest method setupInjectablesInObjectMapper.

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;
}
Also used : LocalLoadSpec(io.druid.segment.loading.LocalLoadSpec) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) Binder(com.google.inject.Binder) Module(com.google.inject.Module) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceAnnotationIntrospector(io.druid.guice.GuiceAnnotationIntrospector) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) GuiceInjectableValues(io.druid.guice.GuiceInjectableValues)

Example 5 with AnnotationIntrospectorPair

use of com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair in project platformlayer by platformlayer.

the class JsonHelper method buildObjectMapper.

public static ObjectMapper buildObjectMapper(TypeFactory typeFactory, boolean formatted) {
    ObjectMapper mapper = new ObjectMapper();
    if (typeFactory == null) {
        typeFactory = TypeFactory.defaultInstance();
    }
    if (formatted) {
        mapper.enable(SerializationFeature.INDENT_OUTPUT);
    }
    // Favor JAXB annotations
    AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(typeFactory);
    AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
    AnnotationIntrospector introspector = new AnnotationIntrospectorPair(jaxbIntrospector, jacksonIntrospector);
    mapper.setAnnotationIntrospector(introspector);
    return mapper;
}
Also used : JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospectorPair(com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair) JacksonAnnotationIntrospector(com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector) AnnotationIntrospector(com.fasterxml.jackson.databind.AnnotationIntrospector) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JaxbAnnotationIntrospector(com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector)

Aggregations

AnnotationIntrospectorPair (com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair)5 Binder (com.google.inject.Binder)3 Module (com.google.inject.Module)3 GuiceAnnotationIntrospector (io.druid.guice.GuiceAnnotationIntrospector)3 GuiceInjectableValues (io.druid.guice.GuiceInjectableValues)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)2 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)2 AnnotationIntrospector (com.fasterxml.jackson.databind.AnnotationIntrospector)1 JacksonAnnotationIntrospector (com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector)1 JaxbAnnotationIntrospector (com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector)1 Injector (com.google.inject.Injector)1 LocalLoadSpec (io.druid.segment.loading.LocalLoadSpec)1 BeforeClass (org.junit.BeforeClass)1