use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project api-core by ca-cwds.
the class ObjectMapperModuleTest method testModulesRegisteredThroughInjectionWithAnnotation.
@Test
public void testModulesRegisteredThroughInjectionWithAnnotation() throws Exception {
final Injector injector = Guice.createInjector(new ObjectMapperModule().registerModule(IntegerAsBase16Module.class, SystemCodeSerializer.class), new Module() {
@Override
public void configure(Binder binder) {
binder.bind(IntegerAsBase16Module.class).annotatedWith(SystemCodeSerializer.class).to(IntegerAsBase16Module.class);
}
});
final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);
Assert.assertEquals(mapper.writeValueAsString(new Integer(10)), "\"A\"");
}
use of com.fasterxml.jackson.module.guice.ObjectMapperModule in project embulk by embulk.
the class ExecModule method configure.
@Override
public void configure(Binder binder) {
Preconditions.checkNotNull(binder, "binder is null.");
binder.bind(BulkLoader.class);
binder.bind(ILoggerFactory.class).toProvider(LoggerProvider.class).in(Scopes.SINGLETON);
binder.bind(ModelManager.class).in(Scopes.SINGLETON);
binder.bind(BufferAllocator.class).to(PooledBufferAllocator.class).in(Scopes.SINGLETON);
binder.bind(TempFileAllocator.class).in(Scopes.SINGLETON);
// GuessExecutor, PreviewExecutor
registerPluginTo(binder, ParserPlugin.class, "system_guess", GuessExecutor.GuessParserPlugin.class);
registerPluginTo(binder, ParserPlugin.class, "system_sampling", SamplingParserPlugin.class);
// LocalExecutorPlugin
registerPluginTo(binder, ExecutorPlugin.class, "local", LocalExecutorPlugin.class);
// serde
ObjectMapperModule mapper = new ObjectMapperModule();
DateTimeZoneSerDe.configure(mapper);
TimestampSerDe.configure(mapper);
CharsetSerDe.configure(mapper);
LocalFileSerDe.configure(mapper);
// jackson-datatype-guava
mapper.registerModule(new GuavaModule());
// jackson-datatype-joda
mapper.registerModule(new JodaModule());
mapper.configure(binder);
}
Aggregations