Search in sources :

Example 1 with GerritInstanceNameModule

use of com.google.gerrit.server.config.GerritInstanceNameModule in project gerrit by GerritCodeReview.

the class Daemon method createSysInjector.

private Injector createSysInjector() {
    final List<Module> modules = new ArrayList<>();
    modules.add(NoteDbSchemaVersionCheck.module());
    modules.add(new DropWizardMetricMaker.RestModule());
    modules.add(new LogFileCompressorModule());
    // Index module shutdown must happen before work queue shutdown, otherwise
    // work queue can get stuck waiting on index futures that will never return.
    modules.add(createIndexModule());
    modules.add(new SubscriptionGraphModule());
    modules.add(new SuperprojectUpdateSubmissionListenerModule());
    modules.add(new WorkQueueModule());
    modules.add(new StreamEventsApiListenerModule());
    modules.add(new EventBrokerModule());
    modules.add(new JdbcAccountPatchReviewStoreModule(config));
    modules.add(new SysExecutorModule());
    modules.add(new DiffExecutorModule());
    modules.add(new MimeUtil2Module());
    modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
    modules.add(new GerritApiModule());
    modules.add(new PluginApiModule());
    modules.add(new SearchingChangeCacheImplModule(replica));
    modules.add(new InternalAccountDirectoryModule());
    modules.add(new DefaultPermissionBackendModule());
    modules.add(new DefaultMemoryCacheModule());
    modules.add(new H2CacheModule());
    modules.add(cfgInjector.getInstance(MailReceiverModule.class));
    if (emailModule != null) {
        modules.add(emailModule);
    } else {
        modules.add(new SmtpEmailSenderModule());
    }
    if (auditEventModule != null) {
        modules.add(auditEventModule);
    } else {
        modules.add(new AuditModule());
    }
    modules.add(new SignedTokenEmailTokenVerifierModule());
    modules.add(new PluginModule());
    if (VersionManager.getOnlineUpgrade(config)) {
        modules.add(new OnlineUpgraderModule());
    }
    modules.add(new OAuthRestModule());
    modules.add(new RestApiModule());
    modules.add(new GpgModule(config));
    modules.add(new StartupChecksModule());
    modules.add(new GerritInstanceNameModule());
    modules.add(new GerritInstanceIdModule());
    if (MoreObjects.firstNonNull(httpd, true)) {
        modules.add(new CanonicalWebUrlModule() {

            @Override
            protected Class<? extends Provider<String>> provider() {
                return HttpCanonicalWebUrlProvider.class;
            }
        });
    } else {
        modules.add(new CanonicalWebUrlModule() {

            @Override
            protected Class<? extends Provider<String>> provider() {
                return CanonicalWebUrlProvider.class;
            }
        });
    }
    modules.add(new DefaultUrlFormatterModule());
    SshSessionFactoryInitializer.init();
    if (sshd) {
        modules.add(SshKeyCacheImpl.module());
    } else {
        modules.add(NoSshKeyCache.module());
    }
    modules.add(new AbstractModule() {

        @Override
        protected void configure() {
            bind(GerritOptions.class).toInstance(new GerritOptions(headless, replica, devCdn));
            if (inMemoryTest) {
                bind(String.class).annotatedWith(SecureStoreClassName.class).toInstance(DefaultSecureStore.class.getName());
                bind(SecureStore.class).toProvider(SecureStoreProvider.class);
            }
        }
    });
    modules.add(new GarbageCollectionModule());
    if (replica) {
        modules.add(new PeriodicGroupIndexerModule());
    } else {
        modules.add(new AccountDeactivatorModule());
        modules.add(new ChangeCleanupRunnerModule());
    }
    modules.add(new LocalMergeSuperSetComputationModule());
    modules.add(new DefaultProjectNameLockManagerModule());
    List<Module> libModules = LibModuleLoader.loadModules(cfgInjector, LibModuleType.SYS_MODULE_TYPE);
    libModules.addAll(LibModuleLoader.loadModules(cfgInjector, LibModuleType.INDEX_MODULE_TYPE));
    libModules.addAll(testSysModules);
    AuthConfig authConfig = cfgInjector.getInstance(AuthConfig.class);
    modules.add(new AuthModule(authConfig));
    modules.add(new ExternalIdCaseSensitivityMigrator.ExternalIdCaseSensitivityMigratorModule());
    return cfgInjector.createChildInjector(ModuleOverloader.override(modules, libModules));
}
Also used : JdbcAccountPatchReviewStoreModule(com.google.gerrit.server.schema.JdbcAccountPatchReviewStore.JdbcAccountPatchReviewStoreModule) RestApiModule(com.google.gerrit.server.restapi.RestApiModule) ArrayList(java.util.ArrayList) AuthConfig(com.google.gerrit.server.config.AuthConfig) HttpPluginModule(com.google.gerrit.httpd.plugins.HttpPluginModule) PluginModule(com.google.gerrit.server.plugins.PluginModule) SmtpEmailSenderModule(com.google.gerrit.server.mail.send.SmtpEmailSender.SmtpEmailSenderModule) DefaultProjectNameLockManagerModule(com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule) GerritGlobalModule(com.google.gerrit.server.config.GerritGlobalModule) SearchingChangeCacheImplModule(com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule) SuperprojectUpdateSubmissionListenerModule(com.google.gerrit.server.update.SuperprojectUpdateSubmissionListener.SuperprojectUpdateSubmissionListenerModule) SysExecutorModule(com.google.gerrit.server.config.SysExecutorModule) DropWizardMetricMaker(com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker) DefaultPermissionBackendModule(com.google.gerrit.server.permissions.DefaultPermissionBackendModule) LogFileCompressorModule(com.google.gerrit.pgm.util.LogFileCompressor.LogFileCompressorModule) GerritOptions(com.google.gerrit.server.config.GerritOptions) SecureStoreProvider(com.google.gerrit.server.securestore.SecureStoreProvider) SignedTokenEmailTokenVerifierModule(com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule) OnlineUpgraderModule(com.google.gerrit.server.index.OnlineUpgrader.OnlineUpgraderModule) DiffExecutorModule(com.google.gerrit.server.patch.DiffExecutorModule) AuditModule(com.google.gerrit.server.audit.AuditModule) SubscriptionGraphModule(com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule) H2CacheModule(com.google.gerrit.server.cache.h2.H2CacheModule) PluginApiModule(com.google.gerrit.server.api.PluginApiModule) CanonicalWebUrlModule(com.google.gerrit.server.config.CanonicalWebUrlModule) OAuthModule(com.google.gerrit.httpd.auth.oauth.OAuthModule) ProjectQoSFilterModule(com.google.gerrit.pgm.http.jetty.ProjectQoSFilter.ProjectQoSFilterModule) InternalAccountDirectoryModule(com.google.gerrit.server.account.InternalAccountDirectory.InternalAccountDirectoryModule) WorkQueueModule(com.google.gerrit.server.git.WorkQueue.WorkQueueModule) SshModule(com.google.gerrit.sshd.SshModule) DefaultPermissionBackendModule(com.google.gerrit.server.permissions.DefaultPermissionBackendModule) ChangeCleanupRunnerModule(com.google.gerrit.server.change.ChangeCleanupRunner.ChangeCleanupRunnerModule) SshAddressesModule(com.google.gerrit.server.ssh.SshAddressesModule) DefaultMemoryCacheModule(com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule) HttpPluginModule(com.google.gerrit.httpd.plugins.HttpPluginModule) DefaultCommandModule(com.google.gerrit.sshd.commands.DefaultCommandModule) WebModule(com.google.gerrit.httpd.WebModule) GetUserFilterModule(com.google.gerrit.httpd.GetUserFilter.GetUserFilterModule) SmtpEmailSenderModule(com.google.gerrit.server.mail.send.SmtpEmailSender.SmtpEmailSenderModule) StreamEventsApiListenerModule(com.google.gerrit.server.events.StreamEventsApiListener.StreamEventsApiListenerModule) PluginModule(com.google.gerrit.server.plugins.PluginModule) IndexModule(com.google.gerrit.server.index.IndexModule) StaticModule(com.google.gerrit.httpd.raw.StaticModule) AccountDeactivatorModule(com.google.gerrit.server.account.AccountDeactivator.AccountDeactivatorModule) AbstractIndexModule(com.google.gerrit.server.index.AbstractIndexModule) JettyModule(com.google.gerrit.pgm.http.jetty.JettyModule) HttpdModule(com.google.gerrit.httpd.HttpdModule) LocalMergeSuperSetComputationModule(com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule) JdbcAccountPatchReviewStoreModule(com.google.gerrit.server.schema.JdbcAccountPatchReviewStore.JdbcAccountPatchReviewStoreModule) SearchingChangeCacheImplModule(com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule) PeriodicGroupIndexerModule(com.google.gerrit.server.group.PeriodicGroupIndexer.PeriodicGroupIndexerModule) GpgModule(com.google.gerrit.gpg.GpgModule) OpenIdModule(com.google.gerrit.httpd.auth.openid.OpenIdModule) AuthModule(com.google.gerrit.auth.AuthModule) SshHostKeyModule(com.google.gerrit.sshd.SshHostKeyModule) DefaultProjectNameLockManagerModule(com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule) OAuthRestModule(com.google.gerrit.httpd.auth.restapi.OAuthRestModule) SignedTokenEmailTokenVerifierModule(com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule) AbstractModule(com.google.inject.AbstractModule) AuthConfigModule(com.google.gerrit.server.config.AuthConfigModule) SequenceCommandsModule(com.google.gerrit.sshd.commands.SequenceCommandsModule) Module(com.google.inject.Module) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) GerritGlobalModule(com.google.gerrit.server.config.GerritGlobalModule) LfsPluginAuthCommandModule(com.google.gerrit.sshd.plugin.LfsPluginAuthCommand.LfsPluginAuthCommandModule) LuceneIndexModule(com.google.gerrit.lucene.LuceneIndexModule) GerritInstanceIdModule(com.google.gerrit.server.config.GerritInstanceIdModule) MimeUtil2Module(com.google.gerrit.server.mime.MimeUtil2Module) SysExecutorModule(com.google.gerrit.server.config.SysExecutorModule) GarbageCollectionModule(com.google.gerrit.server.git.GarbageCollectionModule) GerritAuthModule(com.google.gerrit.httpd.GerritAuthModule) WebSshGlueModule(com.google.gerrit.httpd.WebSshGlueModule) MailReceiverModule(com.google.gerrit.server.mail.receive.MailReceiver.MailReceiverModule) ExternalIdCommandsModule(com.google.gerrit.sshd.commands.ExternalIdCommandsModule) RequireSslFilterModule(com.google.gerrit.httpd.RequireSslFilter.RequireSslFilterModule) OnlineUpgraderModule(com.google.gerrit.server.index.OnlineUpgrader.OnlineUpgraderModule) AuditModule(com.google.gerrit.server.audit.AuditModule) GitOverHttpModule(com.google.gerrit.httpd.GitOverHttpModule) RestApiModule(com.google.gerrit.server.restapi.RestApiModule) LogFileCompressorModule(com.google.gerrit.pgm.util.LogFileCompressor.LogFileCompressorModule) SuperprojectUpdateSubmissionListenerModule(com.google.gerrit.server.update.SuperprojectUpdateSubmissionListener.SuperprojectUpdateSubmissionListenerModule) IndexCommandsModule(com.google.gerrit.sshd.commands.IndexCommandsModule) DiffExecutorModule(com.google.gerrit.server.patch.DiffExecutorModule) NoSshModule(com.google.gerrit.server.ssh.NoSshModule) EventBrokerModule(com.google.gerrit.server.events.EventBroker.EventBrokerModule) StartupChecksModule(com.google.gerrit.server.StartupChecks.StartupChecksModule) GerritApiModule(com.google.gerrit.server.api.GerritApiModule) GerritInstanceNameModule(com.google.gerrit.server.config.GerritInstanceNameModule) LocalMergeSuperSetComputationModule(com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule) MimeUtil2Module(com.google.gerrit.server.mime.MimeUtil2Module) PluginApiModule(com.google.gerrit.server.api.PluginApiModule) ChangeCleanupRunnerModule(com.google.gerrit.server.change.ChangeCleanupRunner.ChangeCleanupRunnerModule) StreamEventsApiListenerModule(com.google.gerrit.server.events.StreamEventsApiListener.StreamEventsApiListenerModule) GarbageCollectionModule(com.google.gerrit.server.git.GarbageCollectionModule) GerritInstanceNameModule(com.google.gerrit.server.config.GerritInstanceNameModule) OAuthRestModule(com.google.gerrit.httpd.auth.restapi.OAuthRestModule) EventBrokerModule(com.google.gerrit.server.events.EventBroker.EventBrokerModule) GpgModule(com.google.gerrit.gpg.GpgModule) GerritApiModule(com.google.gerrit.server.api.GerritApiModule) WorkQueueModule(com.google.gerrit.server.git.WorkQueue.WorkQueueModule) PeriodicGroupIndexerModule(com.google.gerrit.server.group.PeriodicGroupIndexer.PeriodicGroupIndexerModule) StartupChecksModule(com.google.gerrit.server.StartupChecks.StartupChecksModule) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) CanonicalWebUrlModule(com.google.gerrit.server.config.CanonicalWebUrlModule) CanonicalWebUrlProvider(com.google.gerrit.server.config.CanonicalWebUrlProvider) HttpCanonicalWebUrlProvider(com.google.gerrit.httpd.HttpCanonicalWebUrlProvider) SecureStoreProvider(com.google.gerrit.server.securestore.SecureStoreProvider) Provider(com.google.inject.Provider) AbstractModule(com.google.inject.AbstractModule) DefaultMemoryCacheModule(com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule) H2CacheModule(com.google.gerrit.server.cache.h2.H2CacheModule) InternalAccountDirectoryModule(com.google.gerrit.server.account.InternalAccountDirectory.InternalAccountDirectoryModule) MailReceiverModule(com.google.gerrit.server.mail.receive.MailReceiver.MailReceiverModule) OAuthModule(com.google.gerrit.httpd.auth.oauth.OAuthModule) AuthModule(com.google.gerrit.auth.AuthModule) GerritAuthModule(com.google.gerrit.httpd.GerritAuthModule) GerritInstanceIdModule(com.google.gerrit.server.config.GerritInstanceIdModule) ExternalIdCaseSensitivityMigrator(com.google.gerrit.server.account.externalids.ExternalIdCaseSensitivityMigrator) SubscriptionGraphModule(com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule) AccountDeactivatorModule(com.google.gerrit.server.account.AccountDeactivator.AccountDeactivatorModule)

Example 2 with GerritInstanceNameModule

use of com.google.gerrit.server.config.GerritInstanceNameModule in project gerrit by GerritCodeReview.

the class WebAppInitializer method createSysInjector.

private Injector createSysInjector() {
    final List<Module> modules = new ArrayList<>();
    modules.add(new DropWizardMetricMaker.RestModule());
    modules.add(new LogFileCompressorModule());
    modules.add(new EventBrokerModule());
    modules.add(new JdbcAccountPatchReviewStoreModule(config));
    modules.add(cfgInjector.getInstance(GitRepositoryManagerModule.class));
    modules.add(new StreamEventsApiListenerModule());
    modules.add(new SysExecutorModule());
    modules.add(new DiffExecutorModule());
    modules.add(new MimeUtil2Module());
    modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
    modules.add(new GerritApiModule());
    modules.add(new PluginApiModule());
    modules.add(new SearchingChangeCacheImplModule());
    modules.add(new InternalAccountDirectoryModule());
    modules.add(new DefaultPermissionBackendModule());
    modules.add(new DefaultMemoryCacheModule());
    modules.add(new H2CacheModule());
    modules.add(cfgInjector.getInstance(MailReceiverModule.class));
    modules.add(new SmtpEmailSenderModule());
    modules.add(new SignedTokenEmailTokenVerifierModule());
    modules.add(new LocalMergeSuperSetComputationModule());
    modules.add(new AuditModule());
    modules.add(new GpgModule(config));
    modules.add(new StartupChecksModule());
    // Index module shutdown must happen before work queue shutdown, otherwise
    // work queue can get stuck waiting on index futures that will never return.
    modules.add(createIndexModule());
    modules.add(new PluginModule());
    if (VersionManager.getOnlineUpgrade(config)) {
        modules.add(new OnlineUpgraderModule());
    }
    modules.add(new OAuthRestModule());
    modules.add(new RestApiModule());
    modules.add(new SubscriptionGraphModule());
    modules.add(new SuperprojectUpdateSubmissionListenerModule());
    modules.add(new WorkQueueModule());
    modules.add(new GerritInstanceNameModule());
    modules.add(new CanonicalWebUrlModule() {

        @Override
        protected Class<? extends Provider<String>> provider() {
            return HttpCanonicalWebUrlProvider.class;
        }
    });
    modules.add(new DefaultUrlFormatterModule());
    SshSessionFactoryInitializer.init();
    modules.add(SshKeyCacheImpl.module());
    modules.add(new AbstractModule() {

        @Override
        protected void configure() {
            bind(GerritOptions.class).toInstance(new GerritOptions(false, false));
            bind(GerritRuntime.class).toInstance(GerritRuntime.DAEMON);
        }
    });
    modules.add(new GarbageCollectionModule());
    modules.add(new ChangeCleanupRunnerModule());
    modules.add(new AccountDeactivatorModule());
    modules.add(new DefaultProjectNameLockManagerModule());
    modules.add(new ExternalIdCaseSensitivityMigrator.ExternalIdCaseSensitivityMigratorModule());
    return dbInjector.createChildInjector(ModuleOverloader.override(modules, LibModuleLoader.loadModules(cfgInjector, LibModuleType.SYS_MODULE_TYPE)));
}
Also used : JdbcAccountPatchReviewStoreModule(com.google.gerrit.server.schema.JdbcAccountPatchReviewStore.JdbcAccountPatchReviewStoreModule) RestApiModule(com.google.gerrit.server.restapi.RestApiModule) ArrayList(java.util.ArrayList) HttpPluginModule(com.google.gerrit.httpd.plugins.HttpPluginModule) PluginModule(com.google.gerrit.server.plugins.PluginModule) SmtpEmailSenderModule(com.google.gerrit.server.mail.send.SmtpEmailSender.SmtpEmailSenderModule) DefaultProjectNameLockManagerModule(com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule) GerritGlobalModule(com.google.gerrit.server.config.GerritGlobalModule) SearchingChangeCacheImplModule(com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule) SuperprojectUpdateSubmissionListenerModule(com.google.gerrit.server.update.SuperprojectUpdateSubmissionListener.SuperprojectUpdateSubmissionListenerModule) SysExecutorModule(com.google.gerrit.server.config.SysExecutorModule) DropWizardMetricMaker(com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker) DefaultPermissionBackendModule(com.google.gerrit.server.permissions.DefaultPermissionBackendModule) LogFileCompressorModule(com.google.gerrit.pgm.util.LogFileCompressor.LogFileCompressorModule) GerritOptions(com.google.gerrit.server.config.GerritOptions) GitRepositoryManagerModule(com.google.gerrit.server.git.GitRepositoryManagerModule) SignedTokenEmailTokenVerifierModule(com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule) OnlineUpgraderModule(com.google.gerrit.server.index.OnlineUpgrader.OnlineUpgraderModule) DiffExecutorModule(com.google.gerrit.server.patch.DiffExecutorModule) AuditModule(com.google.gerrit.server.audit.AuditModule) SubscriptionGraphModule(com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule) H2CacheModule(com.google.gerrit.server.cache.h2.H2CacheModule) PluginApiModule(com.google.gerrit.server.api.PluginApiModule) CanonicalWebUrlModule(com.google.gerrit.server.config.CanonicalWebUrlModule) OAuthModule(com.google.gerrit.httpd.auth.oauth.OAuthModule) InternalAccountDirectoryModule(com.google.gerrit.server.account.InternalAccountDirectory.InternalAccountDirectoryModule) WorkQueueModule(com.google.gerrit.server.git.WorkQueue.WorkQueueModule) SshModule(com.google.gerrit.sshd.SshModule) DefaultPermissionBackendModule(com.google.gerrit.server.permissions.DefaultPermissionBackendModule) ChangeCleanupRunnerModule(com.google.gerrit.server.change.ChangeCleanupRunner.ChangeCleanupRunnerModule) SshAddressesModule(com.google.gerrit.server.ssh.SshAddressesModule) DefaultMemoryCacheModule(com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule) HttpPluginModule(com.google.gerrit.httpd.plugins.HttpPluginModule) DefaultCommandModule(com.google.gerrit.sshd.commands.DefaultCommandModule) WebModule(com.google.gerrit.httpd.WebModule) SmtpEmailSenderModule(com.google.gerrit.server.mail.send.SmtpEmailSender.SmtpEmailSenderModule) StreamEventsApiListenerModule(com.google.gerrit.server.events.StreamEventsApiListener.StreamEventsApiListenerModule) PluginModule(com.google.gerrit.server.plugins.PluginModule) IndexModule(com.google.gerrit.server.index.IndexModule) StaticModule(com.google.gerrit.httpd.raw.StaticModule) AccountDeactivatorModule(com.google.gerrit.server.account.AccountDeactivator.AccountDeactivatorModule) HttpdModule(com.google.gerrit.httpd.HttpdModule) LocalMergeSuperSetComputationModule(com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule) JdbcAccountPatchReviewStoreModule(com.google.gerrit.server.schema.JdbcAccountPatchReviewStore.JdbcAccountPatchReviewStoreModule) SearchingChangeCacheImplModule(com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule) GpgModule(com.google.gerrit.gpg.GpgModule) OpenIdModule(com.google.gerrit.httpd.auth.openid.OpenIdModule) AuthModule(com.google.gerrit.auth.AuthModule) SshHostKeyModule(com.google.gerrit.sshd.SshHostKeyModule) DefaultProjectNameLockManagerModule(com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule) OAuthRestModule(com.google.gerrit.httpd.auth.restapi.OAuthRestModule) SignedTokenEmailTokenVerifierModule(com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule) AbstractModule(com.google.inject.AbstractModule) GitRepositoryManagerModule(com.google.gerrit.server.git.GitRepositoryManagerModule) AuthConfigModule(com.google.gerrit.server.config.AuthConfigModule) SequenceCommandsModule(com.google.gerrit.sshd.commands.SequenceCommandsModule) Module(com.google.inject.Module) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) GerritGlobalModule(com.google.gerrit.server.config.GerritGlobalModule) LfsPluginAuthCommandModule(com.google.gerrit.sshd.plugin.LfsPluginAuthCommand.LfsPluginAuthCommandModule) LifecycleModule(com.google.gerrit.lifecycle.LifecycleModule) LuceneIndexModule(com.google.gerrit.lucene.LuceneIndexModule) SchemaModule(com.google.gerrit.server.schema.SchemaModule) MimeUtil2Module(com.google.gerrit.server.mime.MimeUtil2Module) SysExecutorModule(com.google.gerrit.server.config.SysExecutorModule) GarbageCollectionModule(com.google.gerrit.server.git.GarbageCollectionModule) GerritAuthModule(com.google.gerrit.httpd.GerritAuthModule) WebSshGlueModule(com.google.gerrit.httpd.WebSshGlueModule) MailReceiverModule(com.google.gerrit.server.mail.receive.MailReceiver.MailReceiverModule) ExternalIdCommandsModule(com.google.gerrit.sshd.commands.ExternalIdCommandsModule) RequireSslFilterModule(com.google.gerrit.httpd.RequireSslFilter.RequireSslFilterModule) GerritServerConfigModule(com.google.gerrit.server.config.GerritServerConfigModule) OnlineUpgraderModule(com.google.gerrit.server.index.OnlineUpgrader.OnlineUpgraderModule) AuditModule(com.google.gerrit.server.audit.AuditModule) GitOverHttpModule(com.google.gerrit.httpd.GitOverHttpModule) RestApiModule(com.google.gerrit.server.restapi.RestApiModule) LogFileCompressorModule(com.google.gerrit.pgm.util.LogFileCompressor.LogFileCompressorModule) SuperprojectUpdateSubmissionListenerModule(com.google.gerrit.server.update.SuperprojectUpdateSubmissionListener.SuperprojectUpdateSubmissionListenerModule) IndexCommandsModule(com.google.gerrit.sshd.commands.IndexCommandsModule) DiffExecutorModule(com.google.gerrit.server.patch.DiffExecutorModule) NoSshModule(com.google.gerrit.server.ssh.NoSshModule) EventBrokerModule(com.google.gerrit.server.events.EventBroker.EventBrokerModule) StartupChecksModule(com.google.gerrit.server.StartupChecks.StartupChecksModule) GerritApiModule(com.google.gerrit.server.api.GerritApiModule) GerritInstanceNameModule(com.google.gerrit.server.config.GerritInstanceNameModule) LocalMergeSuperSetComputationModule(com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule) MimeUtil2Module(com.google.gerrit.server.mime.MimeUtil2Module) PluginApiModule(com.google.gerrit.server.api.PluginApiModule) ChangeCleanupRunnerModule(com.google.gerrit.server.change.ChangeCleanupRunner.ChangeCleanupRunnerModule) StreamEventsApiListenerModule(com.google.gerrit.server.events.StreamEventsApiListener.StreamEventsApiListenerModule) GarbageCollectionModule(com.google.gerrit.server.git.GarbageCollectionModule) GerritInstanceNameModule(com.google.gerrit.server.config.GerritInstanceNameModule) OAuthRestModule(com.google.gerrit.httpd.auth.restapi.OAuthRestModule) EventBrokerModule(com.google.gerrit.server.events.EventBroker.EventBrokerModule) GpgModule(com.google.gerrit.gpg.GpgModule) GerritApiModule(com.google.gerrit.server.api.GerritApiModule) WorkQueueModule(com.google.gerrit.server.git.WorkQueue.WorkQueueModule) StartupChecksModule(com.google.gerrit.server.StartupChecks.StartupChecksModule) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) CanonicalWebUrlModule(com.google.gerrit.server.config.CanonicalWebUrlModule) HttpCanonicalWebUrlProvider(com.google.gerrit.httpd.HttpCanonicalWebUrlProvider) Provider(com.google.inject.Provider) AbstractModule(com.google.inject.AbstractModule) DefaultMemoryCacheModule(com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule) H2CacheModule(com.google.gerrit.server.cache.h2.H2CacheModule) InternalAccountDirectoryModule(com.google.gerrit.server.account.InternalAccountDirectory.InternalAccountDirectoryModule) MailReceiverModule(com.google.gerrit.server.mail.receive.MailReceiver.MailReceiverModule) ExternalIdCaseSensitivityMigrator(com.google.gerrit.server.account.externalids.ExternalIdCaseSensitivityMigrator) SubscriptionGraphModule(com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule) AccountDeactivatorModule(com.google.gerrit.server.account.AccountDeactivator.AccountDeactivatorModule)

Example 3 with GerritInstanceNameModule

use of com.google.gerrit.server.config.GerritInstanceNameModule in project gerrit by GerritCodeReview.

the class InMemoryModule method configure.

@Override
protected void configure() {
    // Do NOT bind @RemotePeer, as it is bound in a child injector of
    // ChangeMergeQueue (bound via GerritGlobalModule below), so there cannot be
    // a binding in the parent injector. If you need @RemotePeer, you must bind
    // it in a child injector of the one containing InMemoryModule. But unless
    // you really need to test something request-scoped, you likely don't
    // actually need it.
    // For simplicity, don't create child injectors, just use this one to get a
    // few required modules.
    Injector cfgInjector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
        }
    });
    bind(GerritRuntime.class).toInstance(GerritRuntime.DAEMON);
    bind(MetricMaker.class).to(DisabledMetricMaker.class);
    install(cfgInjector.getInstance(GerritGlobalModule.class));
    AuthConfig authConfig = cfgInjector.getInstance(AuthConfig.class);
    install(new AuthModule(authConfig));
    install(new GerritApiModule());
    factory(PluginUser.Factory.class);
    install(new PluginApiModule());
    install(new DefaultPermissionBackendModule());
    install(new SearchingChangeCacheImplModule());
    factory(GarbageCollection.Factory.class);
    install(new AuditModule());
    install(new SubscriptionGraphModule());
    install(new SuperprojectUpdateSubmissionListenerModule());
    bindScope(RequestScoped.class, PerThreadRequestScope.REQUEST);
    // It would be nice to use Jimfs for the SitePath, but the biggest blocker is that JGit does not
    // support Path-based Configs, only FileBasedConfig.
    bind(Path.class).annotatedWith(SitePath.class).toInstance(Paths.get("."));
    bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
    bind(GerritOptions.class).toInstance(new GerritOptions(false, false));
    bind(AllProjectsConfigProvider.class).to(FileBasedAllProjectsConfigProvider.class);
    bind(GlobalPluginConfigProvider.class).to(FileBasedGlobalPluginConfigProvider.class);
    bind(GitRepositoryManager.class).to(InMemoryRepositoryManager.class);
    bind(InMemoryRepositoryManager.class).in(SINGLETON);
    bind(TrackingFooters.class).toProvider(TrackingFootersProvider.class).in(SINGLETON);
    bind(SecureStore.class).to(DefaultSecureStore.class);
    install(new InMemorySchemaModule());
    install(NoSshKeyCache.module());
    install(new GerritInstanceNameModule());
    install(new GerritInstanceIdModule());
    install(new CanonicalWebUrlModule() {

        @Override
        protected Class<? extends Provider<String>> provider() {
            return CanonicalWebUrlProvider.class;
        }
    });
    install(new DefaultUrlFormatterModule());
    // Replacement of DiffExecutorModule to not use thread pool in the tests
    install(new AbstractModule() {

        @Override
        protected void configure() {
        }

        @Provides
        @Singleton
        @DiffExecutor
        public ExecutorService createDiffExecutor() {
            return newDirectExecutorService();
        }
    });
    install(new DefaultMemoryCacheModule());
    install(new H2CacheModule());
    install(new FakeEmailSenderModule());
    install(new SignedTokenEmailTokenVerifierModule());
    install(new GpgModule(cfg));
    install(new LocalMergeSuperSetComputationModule());
    bind(AllAccountsIndexer.class).toProvider(Providers.of(null));
    bind(AllChangesIndexer.class).toProvider(Providers.of(null));
    bind(AllGroupsIndexer.class).toProvider(Providers.of(null));
    String indexTypeCfg = cfg.getString("index", null, "type");
    IndexType indexType = new IndexType(indexTypeCfg != null ? indexTypeCfg : "fake");
    // For custom index types, callers must provide their own module.
    if (indexType.isLucene()) {
        install(luceneIndexModule());
    } else if (indexType.isFake()) {
        install(fakeIndexModule());
    }
    bind(ServerInformationImpl.class);
    bind(ServerInformation.class).to(ServerInformationImpl.class);
    install(new RestApiModule());
    install(new OAuthRestModule());
    install(new DefaultProjectNameLockManagerModule());
    install(new FileInfoJsonModule());
    install(new ConfigExperimentFeaturesModule());
    bind(ProjectOperations.class).to(ProjectOperationsImpl.class);
}
Also used : MetricMaker(com.google.gerrit.metrics.MetricMaker) DisabledMetricMaker(com.google.gerrit.metrics.DisabledMetricMaker) RestApiModule(com.google.gerrit.server.restapi.RestApiModule) AuthConfig(com.google.gerrit.server.config.AuthConfig) DefaultProjectNameLockManagerModule(com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule) GerritGlobalModule(com.google.gerrit.server.config.GerritGlobalModule) SearchingChangeCacheImplModule(com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule) GerritRuntime(com.google.gerrit.server.config.GerritRuntime) FakeEmailSenderModule(com.google.gerrit.testing.FakeEmailSender.FakeEmailSenderModule) Injector(com.google.inject.Injector) SuperprojectUpdateSubmissionListenerModule(com.google.gerrit.server.update.SuperprojectUpdateSubmissionListener.SuperprojectUpdateSubmissionListenerModule) ConfigExperimentFeaturesModule(com.google.gerrit.server.experiments.ConfigExperimentFeatures.ConfigExperimentFeaturesModule) AllProjectsConfigProvider(com.google.gerrit.server.config.AllProjectsConfigProvider) FileBasedAllProjectsConfigProvider(com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider) DefaultPermissionBackendModule(com.google.gerrit.server.permissions.DefaultPermissionBackendModule) FileInfoJsonModule(com.google.gerrit.server.change.FileInfoJsonModule) GerritOptions(com.google.gerrit.server.config.GerritOptions) DefaultSecureStore(com.google.gerrit.server.securestore.DefaultSecureStore) SecureStore(com.google.gerrit.server.securestore.SecureStore) SignedTokenEmailTokenVerifierModule(com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule) Singleton(com.google.inject.Singleton) AuditModule(com.google.gerrit.server.audit.AuditModule) SitePath(com.google.gerrit.server.config.SitePath) DiffExecutor(com.google.gerrit.server.patch.DiffExecutor) Config(org.eclipse.jgit.lib.Config) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) AuthConfig(com.google.gerrit.server.config.AuthConfig) FileBasedGlobalPluginConfigProvider(com.google.gerrit.server.config.FileBasedGlobalPluginConfigProvider) GlobalPluginConfigProvider(com.google.gerrit.server.config.GlobalPluginConfigProvider) LocalMergeSuperSetComputationModule(com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule) TrackingFootersProvider(com.google.gerrit.server.config.TrackingFootersProvider) AllChangesIndexer(com.google.gerrit.server.index.change.AllChangesIndexer) GarbageCollection(com.google.gerrit.server.git.GarbageCollection) AllAccountsIndexer(com.google.gerrit.server.index.account.AllAccountsIndexer) PluginApiModule(com.google.gerrit.server.api.PluginApiModule) GerritInstanceNameModule(com.google.gerrit.server.config.GerritInstanceNameModule) ServerInformation(com.google.gerrit.extensions.systemstatus.ServerInformation) OAuthRestModule(com.google.gerrit.httpd.auth.restapi.OAuthRestModule) GpgModule(com.google.gerrit.gpg.GpgModule) GerritApiModule(com.google.gerrit.server.api.GerritApiModule) IndexType(com.google.gerrit.index.IndexType) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) GitRepositoryManager(com.google.gerrit.server.git.GitRepositoryManager) Provides(com.google.inject.Provides) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) AbstractModule(com.google.inject.AbstractModule) CanonicalWebUrlModule(com.google.gerrit.server.config.CanonicalWebUrlModule) FileBasedGlobalPluginConfigProvider(com.google.gerrit.server.config.FileBasedGlobalPluginConfigProvider) AllUsersNameProvider(com.google.gerrit.server.config.AllUsersNameProvider) CanonicalWebUrlProvider(com.google.gerrit.server.config.CanonicalWebUrlProvider) GerritPersonIdentProvider(com.google.gerrit.server.GerritPersonIdentProvider) GlobalPluginConfigProvider(com.google.gerrit.server.config.GlobalPluginConfigProvider) AllProjectsNameProvider(com.google.gerrit.server.config.AllProjectsNameProvider) GerritServerIdProvider(com.google.gerrit.server.config.GerritServerIdProvider) AllProjectsConfigProvider(com.google.gerrit.server.config.AllProjectsConfigProvider) TrackingFootersProvider(com.google.gerrit.server.config.TrackingFootersProvider) FileBasedAllProjectsConfigProvider(com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider) AnonymousCowardNameProvider(com.google.gerrit.server.config.AnonymousCowardNameProvider) Provider(com.google.inject.Provider) DefaultMemoryCacheModule(com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule) H2CacheModule(com.google.gerrit.server.cache.h2.H2CacheModule) AllGroupsIndexer(com.google.gerrit.server.index.group.AllGroupsIndexer) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) MoreExecutors.newDirectExecutorService(com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService) ExecutorService(java.util.concurrent.ExecutorService) AuthModule(com.google.gerrit.auth.AuthModule) GerritInstanceIdModule(com.google.gerrit.server.config.GerritInstanceIdModule) SubscriptionGraphModule(com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule) PluginUser(com.google.gerrit.server.PluginUser)

Aggregations

AuthModule (com.google.gerrit.auth.AuthModule)3 GpgModule (com.google.gerrit.gpg.GpgModule)3 OAuthRestModule (com.google.gerrit.httpd.auth.restapi.OAuthRestModule)3 GerritApiModule (com.google.gerrit.server.api.GerritApiModule)3 PluginApiModule (com.google.gerrit.server.api.PluginApiModule)3 AuditModule (com.google.gerrit.server.audit.AuditModule)3 H2CacheModule (com.google.gerrit.server.cache.h2.H2CacheModule)3 DefaultMemoryCacheModule (com.google.gerrit.server.cache.mem.DefaultMemoryCacheModule)3 CanonicalWebUrlModule (com.google.gerrit.server.config.CanonicalWebUrlModule)3 DefaultUrlFormatterModule (com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule)3 GerritGlobalModule (com.google.gerrit.server.config.GerritGlobalModule)3 GerritInstanceNameModule (com.google.gerrit.server.config.GerritInstanceNameModule)3 GerritOptions (com.google.gerrit.server.config.GerritOptions)3 SearchingChangeCacheImplModule (com.google.gerrit.server.git.SearchingChangeCacheImpl.SearchingChangeCacheImplModule)3 SignedTokenEmailTokenVerifierModule (com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier.SignedTokenEmailTokenVerifierModule)3 DefaultPermissionBackendModule (com.google.gerrit.server.permissions.DefaultPermissionBackendModule)3 DefaultProjectNameLockManagerModule (com.google.gerrit.server.project.DefaultProjectNameLockManager.DefaultProjectNameLockManagerModule)3 RestApiModule (com.google.gerrit.server.restapi.RestApiModule)3 LocalMergeSuperSetComputationModule (com.google.gerrit.server.submit.LocalMergeSuperSetComputation.LocalMergeSuperSetComputationModule)3 SubscriptionGraphModule (com.google.gerrit.server.submit.SubscriptionGraph.SubscriptionGraphModule)3