Search in sources :

Example 81 with FactoryModuleBuilder

use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.

the class Graylog2Module method installSearchResponseDecorator.

protected void installSearchResponseDecorator(MapBinder<String, SearchResponseDecorator.Factory> searchResponseDecoratorBinder, Class<? extends SearchResponseDecorator> searchResponseDecoratorClass, Class<? extends SearchResponseDecorator.Factory> searchResponseDecoratorFactoryClass) {
    install(new FactoryModuleBuilder().implement(SearchResponseDecorator.class, searchResponseDecoratorClass).build(searchResponseDecoratorFactoryClass));
    searchResponseDecoratorBinder.addBinding(searchResponseDecoratorClass.getCanonicalName()).to(searchResponseDecoratorFactoryClass);
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder)

Example 82 with FactoryModuleBuilder

use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.

the class Graylog2Module method installAlertConditionWithCustomName.

protected void installAlertConditionWithCustomName(MapBinder<String, AlertCondition.Factory> alertConditionBinder, String identifier, Class<? extends AlertCondition> alertConditionClass, Class<? extends AlertCondition.Factory> alertConditionFactoryClass) {
    install(new FactoryModuleBuilder().implement(AlertCondition.class, alertConditionClass).build(alertConditionFactoryClass));
    alertConditionBinder.addBinding(identifier).to(alertConditionFactoryClass);
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder)

Example 83 with FactoryModuleBuilder

use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.

the class Graylog2Module method installOutput2.

// This should be used by plugins that have been built for 3.0.1 or later.
// See comments in MessageOutput.Factory and MessageOutput.Factory2 for details
protected <T extends MessageOutput> void installOutput2(MapBinder<String, MessageOutput.Factory2<? extends MessageOutput>> outputMapBinder, Class<T> target, Class<? extends MessageOutput.Factory2<T>> targetFactory) {
    install(new FactoryModuleBuilder().implement(MessageOutput.class, target).build(targetFactory));
    outputMapBinder.addBinding(target.getCanonicalName()).to(Key.get(targetFactory));
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder)

Example 84 with FactoryModuleBuilder

use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.

the class GenericBindings method configure.

@Override
protected void configure() {
    // must not be a singleton!
    bind(LocalMetricRegistry.class).in(Scopes.NO_SCOPE);
    install(new FactoryModuleBuilder().build(DecodingProcessor.Factory.class));
    bind(ProcessBuffer.class).asEagerSingleton();
    if (isMigrationCommand) {
        bind(InputBuffer.class).to(NoopInputBuffer.class);
    } else {
        bind(InputBuffer.class).to(InputBufferImpl.class);
    }
    bind(NodeId.class).toProvider(NodeIdProvider.class);
    if (!isMigrationCommand) {
        bind(ServiceManager.class).toProvider(ServiceManagerProvider.class).asEagerSingleton();
    }
    bind(ThroughputCounter.class);
    bind(EventBus.class).toProvider(EventBusProvider.class).in(Scopes.SINGLETON);
    bind(Semaphore.class).annotatedWith(Names.named("JournalSignal")).toInstance(new Semaphore(0));
    install(new FactoryModuleBuilder().build(new TypeLiteral<IOState.Factory<MessageInput>>() {
    }));
    bind(InputRegistry.class).asEagerSingleton();
    bind(OkHttpClient.class).toProvider(OkHttpClientProvider.class).asEagerSingleton();
    bind(MimetypesFileTypeMap.class).toInstance(new MimetypesFileTypeMap());
    bind(ExecutorService.class).annotatedWith(Names.named("proxiedRequestsExecutorService")).toProvider(ProxiedRequestsExecutorService.class).asEagerSingleton();
    bind(FailureHandler.class).annotatedWith(Names.named("fallbackFailureHandler")).to(DefaultFailureHandler.class).asEagerSingleton();
    Multibinder.newSetBinder(binder(), FailureHandler.class);
    OptionalBinder.newOptionalBinder(binder(), FailureHandlingConfiguration.class).setDefault().to(DefaultFailureHandlingConfiguration.class);
    final MapBinder<String, IndexTemplateProvider> indexTemplateProviderBinder = MapBinder.newMapBinder(binder(), String.class, IndexTemplateProvider.class);
    indexTemplateProviderBinder.addBinding(MessageIndexTemplateProvider.MESSAGE_TEMPLATE_TYPE).to(MessageIndexTemplateProvider.class);
    indexTemplateProviderBinder.addBinding(EventIndexTemplateProvider.EVENT_TEMPLATE_TYPE).to(EventIndexTemplateProvider.class);
    serviceBinder().addBinding().to(FailureHandlingService.class).in(Scopes.SINGLETON);
}
Also used : MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) DefaultFailureHandler(org.graylog.failure.DefaultFailureHandler) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) DefaultFailureHandler(org.graylog.failure.DefaultFailureHandler) FailureHandler(org.graylog.failure.FailureHandler) FailureHandlingService(org.graylog.failure.FailureHandlingService) MessageInput(org.graylog2.plugin.inputs.MessageInput) Semaphore(java.util.concurrent.Semaphore) InputRegistry(org.graylog2.shared.inputs.InputRegistry) MessageIndexTemplateProvider(org.graylog2.indexer.MessageIndexTemplateProvider) EventIndexTemplateProvider(org.graylog2.indexer.EventIndexTemplateProvider) IndexTemplateProvider(org.graylog2.indexer.IndexTemplateProvider) EventBusProvider(org.graylog2.shared.bindings.providers.EventBusProvider) TypeLiteral(com.google.inject.TypeLiteral) ServiceManagerProvider(org.graylog2.shared.bindings.providers.ServiceManagerProvider) ProxiedRequestsExecutorService(org.graylog2.shared.bindings.providers.ProxiedRequestsExecutorService) IOState(org.graylog2.plugin.IOState) NodeId(org.graylog2.plugin.system.NodeId) OkHttpClientProvider(org.graylog2.shared.bindings.providers.OkHttpClientProvider) ProxiedRequestsExecutorService(org.graylog2.shared.bindings.providers.ProxiedRequestsExecutorService) ExecutorService(java.util.concurrent.ExecutorService) NoopInputBuffer(org.graylog2.shared.buffers.NoopInputBuffer) InputBuffer(org.graylog2.plugin.buffers.InputBuffer) ProcessBuffer(org.graylog2.shared.buffers.ProcessBuffer) LocalMetricRegistry(org.graylog2.plugin.LocalMetricRegistry)

Example 85 with FactoryModuleBuilder

use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.

the class SecurityBindings method configure.

@Override
protected void configure() {
    bind(EncryptedValueService.class).asEagerSingleton();
    bind(Permissions.class).asEagerSingleton();
    bind(SessionCreator.class).in(Scopes.SINGLETON);
    addPermissions(RestPermissions.class);
    addInitializer(UserSessionTerminationService.class);
    install(new FactoryModuleBuilder().implement(TrustManager.class, DefaultX509TrustManager.class).build(TrustManagerProvider.class));
    OptionalBinder.newOptionalBinder(binder(), ActorAwareAuthenticationTokenFactory.class).setDefault().to(ActorAwareUsernamePasswordTokenFactory.class);
    OptionalBinder.newOptionalBinder(binder(), SessionResponseFactory.class).setDefault().to(DefaultSessionResponseFactory.class);
}
Also used : TrustManagerProvider(org.graylog2.security.TrustManagerProvider) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) EncryptedValueService(org.graylog2.security.encryption.EncryptedValueService)

Aggregations

FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)85 AbstractModule (com.google.inject.AbstractModule)20 Injector (com.google.inject.Injector)12 ConfigModule (co.cask.cdap.common.guice.ConfigModule)10 PrivateModule (com.google.inject.PrivateModule)10 DatasetDefinitionRegistry (co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry)8 DefaultDatasetDefinitionRegistry (co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry)8 InMemoryDatasetFramework (co.cask.cdap.data2.dataset2.InMemoryDatasetFramework)8 TypeLiteral (com.google.inject.TypeLiteral)8 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)7 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)6 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)6 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)6 DatasetOpExecutor (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor)6 DatasetDefinitionRegistryFactory (co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory)6 Singleton (com.google.inject.Singleton)6 TransactionManager (org.apache.tephra.TransactionManager)6 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)5 DatasetAdminOpHTTPHandler (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpHTTPHandler)5 CConfiguration (co.cask.cdap.common.conf.CConfiguration)4