use of com.google.inject.Provides in project druid by druid-io.
the class MetricsModule method getMonitorScheduler.
@Provides
@ManageLifecycle
public MonitorScheduler getMonitorScheduler(Supplier<DruidMonitorSchedulerConfig> config, MonitorsConfig monitorsConfig, Set<Class<? extends Monitor>> monitorSet, ServiceEmitter emitter, Injector injector) {
List<Monitor> monitors = Lists.newArrayList();
for (Class<? extends Monitor> monitorClass : Iterables.concat(monitorsConfig.getMonitors(), monitorSet)) {
final Monitor monitor = injector.getInstance(monitorClass);
log.info("Adding monitor[%s]", monitor);
monitors.add(monitor);
}
return new MonitorScheduler(config.get(), Execs.scheduledSingleThreaded("MonitorScheduler-%s"), emitter, monitors);
}
use of com.google.inject.Provides in project druid by druid-io.
the class ChatHandlerServerModule method getServer.
@Provides
@LazySingleton
@RemoteChatHandler
public Server getServer(Injector injector, Lifecycle lifecycle, @RemoteChatHandler DruidNode node, @RemoteChatHandler ServerConfig config) {
final Server server = JettyServerModule.makeJettyServer(node, config);
JettyServerModule.initializeServer(injector, lifecycle, server);
return server;
}
use of com.google.inject.Provides in project druid by druid-io.
the class JettyServerModule method getJacksonSmileProvider.
@Provides
@Singleton
public JacksonSmileProvider getJacksonSmileProvider(@Smile ObjectMapper objectMapper) {
final JacksonSmileProvider provider = new JacksonSmileProvider();
provider.setMapper(objectMapper);
return provider;
}
use of com.google.inject.Provides in project druid by druid-io.
the class JettyServerModule method getJacksonJsonProvider.
@Provides
@Singleton
public JacksonJsonProvider getJacksonJsonProvider(@Json ObjectMapper objectMapper) {
final JacksonJsonProvider provider = new JacksonJsonProvider();
provider.setMapper(objectMapper);
return provider;
}
use of com.google.inject.Provides in project OpenAM by OpenRock.
the class CoreGuiceModule method getCTSObjectMapper.
/**
* CTS Jackson Object Mapper.
* <p>
* Use a static singleton as per <a href="http://wiki.fasterxml.com/JacksonBestPracticesPerformance">performance
* best practice.</a>
*/
@Provides
@Named(CoreTokenConstants.OBJECT_MAPPER)
@Singleton
ObjectMapper getCTSObjectMapper() {
ObjectMapper mapper = new ObjectMapper().configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true).configure(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
/**
* @see http://stackoverflow.com/questions/7105745/how-to-specify-jackson-to-only-use-fields-preferably-globally
*/
mapper.setVisibilityChecker(mapper.getSerializationConfig().getDefaultVisibilityChecker().withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE).withIsGetterVisibility(JsonAutoDetect.Visibility.NONE).withSetterVisibility(JsonAutoDetect.Visibility.NONE).withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
SimpleModule customModule = new SimpleModule("openam", Version.unknownVersion());
customModule.addKeyDeserializer(SessionID.class, new SessionIDKeyDeserialiser());
mapper.registerModule(customModule);
mapper.addHandler(new CompatibilityProblemHandler());
return mapper;
}
Aggregations