Example usage for com.fasterxml.jackson.databind.jsontype NamedType NamedType

List of usage examples for com.fasterxml.jackson.databind.jsontype NamedType NamedType

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.jsontype NamedType NamedType.

Prototype

public NamedType(Class<?> paramClass, String paramString) 

Source Link

Usage

From source file:com.spotify.ffwd.module.PluginContextImpl.java

@Override
public void registerInput(String name, Class<? extends InputPlugin> input) {
    module.registerSubtypes(new NamedType(input, name));
}

From source file:com.spotify.ffwd.module.PluginContextImpl.java

@Override
public void registerOutput(String name, Class<? extends OutputPlugin> output) {
    module.registerSubtypes(new NamedType(output, name));
}

From source file:io.druid.extension.lucene.LuceneDruidModule.java

@Override
public List<? extends Module> getJacksonModules() {
    return ImmutableList.of(new SimpleModule(LuceneDruidModule.class.getSimpleName()).registerSubtypes(
            new NamedType(AppenderatorPlumberSchool.class, "appenderator"),
            new NamedType(LuceneDruidQuery.class, "lucene")));
}

From source file:com.spotify.ffwd.module.PluginContextImpl.java

@Override
public void registerSerializer(String name, Class<? extends Serializer> serializer) {
    module.registerSubtypes(new NamedType(serializer, name));
}

From source file:io.druid.query.aggregation.HyperloglogDruidModule.java

@Override
public List<? extends Module> getJacksonModules() {
    return ImmutableList.of(new HyperloglogJacksonSerdeModule()
            .registerSubtypes(new NamedType(HyperloglogAggregatorFactory.class, "hyperloglog")));
}

From source file:io.druid.segment.loading.LocalDataSegmentFinderTest.java

@BeforeClass
public static void setUpStatic() {
    mapper.registerSubtypes(new NamedType(NumberedShardSpec.class, "numbered"));
}

From source file:io.druid.segment.loading.HdfsDataSegmentFinderTest.java

@BeforeClass
public static void setupStatic() throws IOException {
    mapper.registerSubtypes(new NamedType(NumberedShardSpec.class, "numbered"));

    hdfsTmpDir = File.createTempFile("hdfsDataSource", "dir");
    hdfsTmpDir.deleteOnExit();/*from w w w  . j a v  a  2s  . c om*/
    if (!hdfsTmpDir.delete()) {
        throw new IOException(String.format("Unable to delete hdfsTmpDir [%s]", hdfsTmpDir.getAbsolutePath()));
    }
    conf = new Configuration(true);
    conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, hdfsTmpDir.getAbsolutePath());
    miniCluster = new MiniDFSCluster.Builder(conf).build();
    uriBase = miniCluster.getURI();
    fs = miniCluster.getFileSystem();
}

From source file:com.flipkart.foxtrot.server.util.ManagedActionScanner.java

@Override
public void start() throws Exception {
    Reflections reflections = new Reflections("com.flipkart.foxtrot", new SubTypesScanner());
    Set<Class<? extends Action>> actions = reflections.getSubTypesOf(Action.class);
    if (actions.isEmpty()) {
        throw new Exception("No analytics actions found!!");
    }/*from   w  ww.  j  a  v a2 s. c  om*/
    List<NamedType> types = new Vector<NamedType>();
    for (Class<? extends Action> action : actions) {
        AnalyticsProvider analyticsProvider = action.getAnnotation(AnalyticsProvider.class);
        if (null == analyticsProvider.request() || null == analyticsProvider.opcode()
                || analyticsProvider.opcode().isEmpty() || null == analyticsProvider.response()) {
            throw new Exception("Invalid annotation on " + action.getCanonicalName());
        }
        if (analyticsProvider.opcode().equalsIgnoreCase("default")) {
            logger.warn("Action " + action.getCanonicalName() + " does not specify cache token. "
                    + "Using default cache.");
        }
        analyticsLoader.register(new ActionMetadata(analyticsProvider.request(), action,
                analyticsProvider.cacheable(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.request(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.response(), analyticsProvider.opcode()));
        logger.info("Registered action: " + action.getCanonicalName());
    }
    SubtypeResolver subtypeResolver = environment.getObjectMapperFactory().getSubtypeResolver();
    subtypeResolver.registerSubtypes(types.toArray(new NamedType[types.size()]));
}

From source file:com.flipkart.foxtrot.core.TestUtils.java

public static void registerActions(AnalyticsLoader analyticsLoader, ObjectMapper mapper) throws Exception {
    Reflections reflections = new Reflections("com.flipkart.foxtrot", new SubTypesScanner());
    Set<Class<? extends Action>> actions = reflections.getSubTypesOf(Action.class);
    if (actions.isEmpty()) {
        throw new Exception("No analytics actions found!!");
    }/*www.j  a v a 2  s.c om*/
    List<NamedType> types = new Vector<NamedType>();
    for (Class<? extends Action> action : actions) {
        AnalyticsProvider analyticsProvider = action.getAnnotation(AnalyticsProvider.class);
        if (null == analyticsProvider.request() || null == analyticsProvider.opcode()
                || analyticsProvider.opcode().isEmpty() || null == analyticsProvider.response()) {
            throw new Exception("Invalid annotation on " + action.getCanonicalName());
        }
        if (analyticsProvider.opcode().equalsIgnoreCase("default")) {
            logger.warn("Action " + action.getCanonicalName() + " does not specify cache token. "
                    + "Using default cache.");
        }
        analyticsLoader.register(new ActionMetadata(analyticsProvider.request(), action,
                analyticsProvider.cacheable(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.request(), analyticsProvider.opcode()));
        types.add(new NamedType(analyticsProvider.response(), analyticsProvider.opcode()));
        logger.info("Registered action: " + action.getCanonicalName());
    }
    mapper.getSubtypeResolver().registerSubtypes(types.toArray(new NamedType[types.size()]));
}

From source file:io.dropwizard.primer.PrimerBundle.java

@Override
public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.getObjectMapper().registerSubtypes(new NamedType(PrimerSimpleEndpoint.class, "simple"));
    bootstrap.getObjectMapper().registerSubtypes(new NamedType(PrimerRangerEndpoint.class, "ranger"));
}