use of com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule 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));
}
use of com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule 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)));
}
use of com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule in project gerrit by GerritCodeReview.
the class AbstractChangeNotesTest method setUpTestEnvironment.
// TODO(issue-15517): Fix the JdkObsolete issue with Date once JGit's PersonIdent class supports
// Instants
@SuppressWarnings("JdkObsolete")
@Before
public void setUpTestEnvironment() throws Exception {
setTimeForTesting();
serverIdent = new PersonIdent("Gerrit Server", "noreply@gerrit.com", Date.from(TimeUtil.now()), TZ);
project = Project.nameKey("test-project");
repoManager = new InMemoryRepositoryManager();
repo = repoManager.createRepository(project);
tr = new TestRepository<>(repo);
rw = tr.getRevWalk();
accountCache = new FakeAccountCache();
Account.Builder co = Account.builder(Account.id(1), TimeUtil.now());
co.setFullName("Change Owner");
co.setPreferredEmail("change@owner.com");
accountCache.put(co.build());
Account.Builder ou = Account.builder(Account.id(2), TimeUtil.now());
ou.setFullName("Other Account");
ou.setPreferredEmail("other@account.com");
accountCache.put(ou.build());
assertableFanOutExecutor = new AssertableExecutorService();
injector = Guice.createInjector(new FactoryModule() {
@Override
public void configure() {
install(new GitModule());
install(new DefaultUrlFormatterModule());
install(NoteDbModule.forTest());
bind(AllUsersName.class).toProvider(AllUsersNameProvider.class);
bind(String.class).annotatedWith(GerritServerId.class).toInstance("gerrit");
bind(GitRepositoryManager.class).toInstance(repoManager);
bind(ProjectCache.class).to(NullProjectCache.class);
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(testConfig);
bind(String.class).annotatedWith(AnonymousCowardName.class).toProvider(AnonymousCowardNameProvider.class);
bind(String.class).annotatedWith(CanonicalWebUrl.class).toInstance("http://localhost:8080/");
bind(Boolean.class).annotatedWith(EnablePeerIPInReflogRecord.class).toInstance(Boolean.FALSE);
bind(Realm.class).to(FakeRealm.class);
bind(GroupBackend.class).to(SystemGroupBackend.class).in(SINGLETON);
bind(AccountCache.class).toInstance(accountCache);
bind(PersonIdent.class).annotatedWith(GerritPersonIdent.class).toInstance(serverIdent);
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
bind(MetricMaker.class).to(DisabledMetricMaker.class);
bind(ExecutorService.class).annotatedWith(FanOutExecutor.class).toInstance(assertableFanOutExecutor);
bind(ServiceUserClassifier.class).to(ServiceUserClassifier.NoOp.class);
bind(InternalChangeQuery.class).toProvider(() -> {
throw new UnsupportedOperationException();
});
bind(PatchSetApprovalUuidGenerator.class).to(TestPatchSetApprovalUuidGenerator.class);
}
});
injector.injectMembers(this);
repoManager.createRepository(allUsers);
changeOwner = userFactory.create(co.id());
otherUser = userFactory.create(ou.id());
otherUserId = otherUser.getAccountId();
internalUser = new InternalUser();
}
use of com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule 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);
}
use of com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule in project gerrit by GerritCodeReview.
the class BatchProgramModule method configure.
@SuppressWarnings("rawtypes")
@Override
protected void configure() {
List<Module> modules = new ArrayList<>();
modules.add(new DiffExecutorModule());
modules.add(new SysExecutorModule());
modules.add(BatchUpdate.module());
modules.add(PatchListCacheImpl.module());
modules.add(new DefaultUrlFormatterModule());
modules.add(DiffOperationsImpl.module());
// There is the concept of LifecycleModule, in Gerrit's own extension to Guice, which has these:
// listener().to(SomeClassImplementingLifecycleListener.class);
// and the start() methods of each such listener are executed in the order they are declared.
// Makes sure that PluginLoader.start() is executed before the LuceneIndexModule.start() so that
// plugins get loaded and the respective Guice modules installed so that the on-line reindexing
// will happen with the proper classes (e.g. group backends, custom Prolog predicates) and the
// associated rules ready to be evaluated.
modules.add(new PluginModule());
// We're just running through each change
// once, so don't worry about cache removal.
bind(new TypeLiteral<DynamicSet<CacheRemovalListener>>() {
}).toInstance(DynamicSet.emptySet());
DynamicMap.mapOf(binder(), new TypeLiteral<Cache<?, ?>>() {
});
bind(new TypeLiteral<List<CommentLinkInfo>>() {
}).toProvider(CommentLinkProvider.class).in(SINGLETON);
bind(new TypeLiteral<DynamicMap<RestView<CommitResource>>>() {
}).toInstance(DynamicMap.emptyMap());
bind(String.class).annotatedWith(CanonicalWebUrl.class).toProvider(CanonicalWebUrlProvider.class);
bind(Boolean.class).annotatedWith(EnablePeerIPInReflogRecord.class).toProvider(EnablePeerIPInReflogRecordProvider.class).in(SINGLETON);
bind(Realm.class).to(FakeRealm.class);
bind(IdentifiedUser.class).toProvider(Providers.of(null));
bind(ReplacePatchSetSender.Factory.class).toProvider(Providers.of(null));
bind(CurrentUser.class).to(IdentifiedUser.class);
factory(MergeUtil.Factory.class);
factory(PatchSetInserter.Factory.class);
factory(RebaseChangeOp.Factory.class);
// As Reindex is a batch program, don't assume the index is available for
// the change cache.
bind(SearchingChangeCacheImpl.class).toProvider(Providers.of(null));
bind(new TypeLiteral<ImmutableSet<GroupReference>>() {
}).annotatedWith(AdministrateServerGroups.class).toInstance(ImmutableSet.of());
bind(new TypeLiteral<Set<AccountGroup.UUID>>() {
}).annotatedWith(GitUploadPackGroups.class).toInstance(Collections.emptySet());
bind(new TypeLiteral<Set<AccountGroup.UUID>>() {
}).annotatedWith(GitReceivePackGroups.class).toInstance(Collections.emptySet());
modules.add(new BatchGitModule());
modules.add(new DefaultPermissionBackendModule());
modules.add(new DefaultMemoryCacheModule());
modules.add(new H2CacheModule());
modules.add(new ExternalIdCacheModule());
modules.add(new GroupModule());
modules.add(new NoteDbModule());
modules.add(AccountCacheImpl.module());
modules.add(ConflictsCacheImpl.module());
modules.add(DefaultPreferencesCacheImpl.module());
modules.add(GroupCacheImpl.module());
modules.add(GroupIncludeCacheImpl.module());
modules.add(ProjectCacheImpl.module());
modules.add(SectionSortCache.module());
modules.add(ChangeKindCacheImpl.module());
modules.add(MergeabilityCacheImpl.module());
modules.add(ServiceUserClassifierImpl.module());
modules.add(TagCache.module());
modules.add(PureRevertCache.module());
modules.add(new ApprovalModule());
modules.add(SubmitRequirementsEvaluatorImpl.module());
factory(CapabilityCollection.Factory.class);
factory(ChangeData.AssistedFactory.class);
factory(ChangeIsVisibleToPredicate.Factory.class);
factory(DistinctVotersPredicate.Factory.class);
factory(ProjectState.Factory.class);
DynamicMap.mapOf(binder(), ChangeQueryBuilder.ChangeOperatorFactory.class);
DynamicMap.mapOf(binder(), ChangeQueryBuilder.ChangeHasOperandFactory.class);
DynamicMap.mapOf(binder(), ChangeQueryBuilder.ChangeIsOperandFactory.class);
// Submit rules
DynamicSet.setOf(binder(), SubmitRule.class);
factory(SubmitRuleEvaluator.Factory.class);
modules.add(new PrologModule());
modules.add(new DefaultSubmitRuleModule());
modules.add(new IgnoreSelfApprovalRuleModule());
// Global submit requirements
DynamicSet.setOf(binder(), SubmitRequirement.class);
factory(FileEditsPredicate.Factory.class);
bind(ChangeJson.Factory.class).toProvider(Providers.of(null));
bind(EventUtil.class).toProvider(Providers.of(null));
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
bind(RevisionCreated.class).toInstance(RevisionCreated.DISABLED);
bind(WorkInProgressStateChanged.class).toInstance(WorkInProgressStateChanged.DISABLED);
bind(AccountVisibility.class).toProvider(AccountVisibilityProvider.class).in(SINGLETON);
ModuleOverloader.override(modules, LibModuleLoader.loadModules(parentInjector, LibModuleType.SYS_BATCH_MODULE_TYPE)).stream().forEach(this::install);
}
Aggregations