Search in sources :

Example 31 with Provides

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);
}
Also used : ExecutorServiceMonitor(io.druid.query.ExecutorServiceMonitor) Monitor(com.metamx.metrics.Monitor) JvmCpuMonitor(com.metamx.metrics.JvmCpuMonitor) JvmMonitor(com.metamx.metrics.JvmMonitor) SysMonitor(com.metamx.metrics.SysMonitor) MonitorScheduler(com.metamx.metrics.MonitorScheduler) ManageLifecycle(io.druid.guice.ManageLifecycle) Provides(com.google.inject.Provides)

Example 32 with Provides

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;
}
Also used : Server(org.eclipse.jetty.server.Server) RemoteChatHandler(io.druid.guice.annotations.RemoteChatHandler) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 33 with Provides

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;
}
Also used : JacksonSmileProvider(com.fasterxml.jackson.jaxrs.smile.JacksonSmileProvider) LazySingleton(io.druid.guice.LazySingleton) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 34 with Provides

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;
}
Also used : JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) LazySingleton(io.druid.guice.LazySingleton) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 35 with Provides

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;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)126 Singleton (javax.inject.Singleton)36 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)24 Injector (com.google.inject.Injector)22 Named (javax.inject.Named)17 LazySingleton (io.druid.guice.LazySingleton)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 IOException (java.io.IOException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 Binder (com.google.inject.Binder)3