Example usage for com.fasterxml.jackson.databind.module SimpleModule setMixInAnnotation

List of usage examples for com.fasterxml.jackson.databind.module SimpleModule setMixInAnnotation

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.module SimpleModule setMixInAnnotation.

Prototype

public SimpleModule setMixInAnnotation(Class<?> targetType, Class<?> mixinClass) 

Source Link

Document

Method for specifying that annotations define by mixinClass should be "mixed in" with annotations that targetType has (as if they were directly included on it!).

Usage

From source file:org.zalando.problem.ProblemModule.java

@Override
public void setupModule(final SetupContext context) {
    final SimpleModule module = new SimpleModule();

    module.setMixInAnnotation(Exceptional.class,
            stacktraces ? ExceptionalWithStacktraceMixin.class : ExceptionalMixin.class);

    module.setMixInAnnotation(DefaultProblem.class, DefaultProblemMixIn.class);
    module.setMixInAnnotation(Problem.class, ProblemMixIn.class);

    module.addSerializer(StatusType.class, new StatusTypeSerializer());
    module.addDeserializer(StatusType.class, new StatusTypeDeserializer(statuses));

    module.setupModule(context);/*from w  w w .j  ava2 s.  c o m*/
}

From source file:com.spotify.ffwd.AgentCore.java

/**
 * Setup early application Injector./* w  w  w .  j a  v  a2s. c o m*/
 *
 * The early injector is used by modules to configure the system.
 *
 * @throws Exception If something could not be set up.
 */
private Injector setupEarlyInjector() throws Exception {
    final List<Module> modules = Lists.newArrayList();

    modules.add(new AbstractModule() {
        @Singleton
        @Provides
        @Named("application/yaml+config")
        public SimpleModule configModule() {
            final SimpleModule module = new SimpleModule();

            // Make InputPlugin, and OutputPlugin sub-type aware through the 'type' attribute.
            module.setMixInAnnotation(InputPlugin.class, FasterXmlSubTypeMixIn.class);
            module.setMixInAnnotation(OutputPlugin.class, FasterXmlSubTypeMixIn.class);

            return module;
        }

        @Override
        protected void configure() {
            bind(PluginContext.class).to(PluginContextImpl.class).in(Scopes.SINGLETON);
        }
    });

    final Injector injector = Guice.createInjector(modules);

    for (final FastForwardModule m : loadModules(injector)) {
        log.info("Setting up {}", m);

        try {
            m.setup();
        } catch (Exception e) {
            throw new Exception("Failed to call #setup() for module: " + m, e);
        }
    }

    return injector;
}