use of com.google.inject.assistedinject.FactoryModuleBuilder in project gerrit by GerritCodeReview.
the class ChangeExternalIdCaseSensitivity method run.
@Override
public int run() throws Exception {
mustHaveValidSite();
ui = ConsoleUI.getInstance(batch);
Injector dbInjector = createDbInjector();
manager.add(dbInjector, dbInjector.createChildInjector(NoteDbSchemaVersionCheck.module()));
dbInjector.createChildInjector(new FactoryModule() {
@Override
protected void configure() {
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
install(new FactoryModuleBuilder().build(ExternalIdCaseSensitivityMigrator.Factory.class));
factory(MetaDataUpdate.InternalFactory.class);
DynamicMap.mapOf(binder(), ExternalIdUpsertPreprocessor.class);
// The ChangeExternalIdCaseSensitivity program needs to access all external IDs only
// once to update them. After the update they are not accessed again. Hence the
// LocalUsernamesToLowerCase program doesn't benefit from caching external IDs and
// the external ID cache can be disabled.
install(DisabledExternalIdCache.module());
}
}).injectMembers(this);
globalConfig = dbInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
this.isUserNameCaseInsensitive = globalConfig.getBoolean("auth", "userNameCaseInsensitive", false);
String message = "auth.userNameCaseInsensitive is set to %b. " + "External IDs will be migrated to be case %ssensitive. Continue?";
if (!ui.yesno(true, message, isUserNameCaseInsensitive, isUserNameCaseInsensitive ? "" : "in")) {
return 0;
}
Collection<ExternalId> todo = externalIds.all();
monitor.beginTask("Converting external ID note names", todo.size());
manager.start();
try {
migratorFactory.create(!isUserNameCaseInsensitive, dryrun).migrate(todo, () -> monitor.update(1));
} finally {
manager.stop();
monitor.endTask();
}
int exitCode;
if (!dryrun) {
updateGerritConfig();
exitCode = reindexAccounts();
} else {
exitCode = 0;
}
return exitCode;
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project scdl by passy.
the class SCDLModule method configure.
@Override
protected void configure() {
bind(URLConnectionFactory.class).to(URLConnectionFactoryImpl.class);
bind(PinningTrustManager.class).toProvider(PinningTrustManagerProvider.class);
bind(DownloadManager.class).toProvider(DownloadManagerProvider.class);
bind(ActionBar.class).toProvider(ActionBarProvider.class);
bind(IabHelper.class).toProvider(IabHelperProvider.class);
bind(PackageManager.class).toProvider(PackageManagerProvider.class);
// Share one instance of the Bus across the application.
// If I ever need more than one, I could just use a Named() annotation.
bind(Bus.class).toProvider(BusProvider.class).in(Singleton.class);
// This must be a Singleton. Google advices to handle the creation in the Application.
bind(Tracker.class).toProvider(TrackerProvider.class).in(Singleton.class);
install(new FactoryModuleBuilder().implement(URLWrapper.class, URLWrapperImpl.class).build(URLWrapperFactory.class));
install(new FactoryModuleBuilder().implement(TrackDownloader.class, TrackDownloaderImpl.class).build(TrackDownloaderFactory.class));
install(new FactoryModuleBuilder().implement(DownloadPreferencesDelegate.class, DownloadPreferencesDelegateImpl.class).build(DownloadPreferencesDelegateFactory.class));
install(new FactoryModuleBuilder().implement(PreferenceManagerWrapper.class, PreferenceManagerWrapperImpl.class).build(PreferenceManagerWrapperFactory.class));
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project gerrit by GerritCodeReview.
the class FakeIndexModuleOnInit method configure.
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(AccountIndex.class, FakeAccountIndex.class).build(AccountIndex.Factory.class));
install(new FactoryModuleBuilder().implement(GroupIndex.class, FakeGroupIndex.class).build(GroupIndex.Factory.class));
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project blueocean-plugin by jenkinsci.
the class AthModule method configure.
@Override
protected void configure() {
Config cfg = new Config();
File userConfig = new File(new File(System.getProperty("user.home")), ".blueocean-ath-config");
if (userConfig.canRead()) {
cfg.loadProps(userConfig);
}
bind(Config.class).toInstance(cfg);
String webDriverType = cfg.getString("webDriverType");
MutableCapabilities capability;
if ("firefox".equals(webDriverType)) {
capability = new FirefoxOptions();
} else {
capability = new ChromeOptions();
}
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capability.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
String webDriverUrl = cfg.getString("webDriverUrl", "http://localhost:4444/wd/hub");
String webDriverBrowserSize = cfg.getString("webDriverBrowserSize");
try {
String launchUrl = cfg.getString("jenkinsUrl");
if (launchUrl == null) {
launchUrl = new String(Files.readAllBytes(Paths.get("runner/.blueocean-ath-jenkins-url")));
}
capability.setCapability("extendedDebugging", "true");
capability.setCapability("initialBrowserUrl", launchUrl);
if (!StringUtils.isBlank(cfg.getString("TUNNEL_IDENTIFIER"))) {
capability.setCapability("tunnelIdentifier", cfg.getString("TUNNEL_IDENTIFIER"));
}
WebDriver driver = new RemoteWebDriver(new URL(webDriverUrl), capability);
LocalDriver.setCurrent(driver);
driver = new Augmenter().augment(driver);
if (webDriverBrowserSize == null) {
driver.manage().window().maximize();
} else {
String[] widthXHeight = webDriverBrowserSize.split("x");
driver.manage().window().setSize(new Dimension(Integer.parseInt(widthXHeight[0]), Integer.parseInt(widthXHeight[1])));
}
driver.manage().deleteAllCookies();
bind(WebDriver.class).toInstance(driver);
bindConstant().annotatedWith(BaseUrl.class).to(launchUrl);
LocalDriver.setUrlBase(launchUrl);
JenkinsUser admin = new JenkinsUser(cfg.getString("adminUsername", "alice"), cfg.getString("adminPassword", "alice"));
bind(JenkinsUser.class).toInstance(admin);
CustomJenkinsServer server = new CustomJenkinsServer(new URI(launchUrl), admin);
bind(JenkinsServer.class).toInstance(server);
bind(CustomJenkinsServer.class).toInstance(server);
if (server.getComputerSet().getTotalExecutors() < 10) {
server.runScript("jenkins.model.Jenkins.get().setNumExecutors(10);\n" + "jenkins.model.Jenkins.get().save();\n", true);
}
Properties properties = new Properties();
File liveProperties = new File("live.properties");
if (liveProperties.canRead()) {
properties.load(new FileInputStream(liveProperties));
}
bind(Properties.class).annotatedWith(Names.named("live")).toInstance(properties);
} catch (Exception e) {
LocalDriver.destroy();
throw new RuntimeException(e);
}
install(new FactoryModuleBuilder().implement(ActivityPage.class, ActivityPage.class).build(ActivityPageFactory.class));
install(new FactoryModuleBuilder().implement(MultiBranchPipeline.class, MultiBranchPipeline.class).build(MultiBranchPipelineFactory.class));
install(new FactoryModuleBuilder().implement(FreestyleJob.class, FreestyleJob.class).build(FreestyleJobFactory.class));
install(new FactoryModuleBuilder().implement(ClassicPipeline.class, ClassicPipeline.class).build(ClassicPipelineFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsPipelinePage.class, RunDetailsPipelinePage.class).build(RunDetailsPipelinePageFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsArtifactsPage.class, RunDetailsArtifactsPage.class).build(RunDetailsArtifactsPageFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsTestsPage.class, RunDetailsTestsPage.class).build(RunDetailsTestsPageFactory.class));
install(new FactoryModuleBuilder().implement(BranchPage.class, BranchPage.class).build(BranchPageFactory.class));
install(new FactoryModuleBuilder().implement(PullRequestsPage.class, PullRequestsPage.class).build(PullRequestsPageFactory.class));
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project graylog2-server by Graylog2.
the class EventsModule method configure.
@Override
protected void configure() {
bind(EventProcessorEngine.class).asEagerSingleton();
bind(EventStorageHandlerEngine.class).asEagerSingleton();
bind(EventFieldSpecEngine.class).asEagerSingleton();
bind(EventIndexer.class).asEagerSingleton();
bind(NotificationGracePeriodService.class).asEagerSingleton();
bind(EventProcessorExecutionMetrics.class).asEagerSingleton();
bind(EventNotificationExecutionMetrics.class).asEagerSingleton();
addSystemRestResource(AvailableEntityTypesResource.class);
addSystemRestResource(EventDefinitionsResource.class);
addSystemRestResource(EventNotificationsResource.class);
addSystemRestResource(EventsResource.class);
addPeriodical(EventNotificationStatusCleanUp.class);
addEntityFacade(ModelTypes.EVENT_DEFINITION_V1, EventDefinitionFacade.class);
addEntityFacade(ModelTypes.NOTIFICATION_V1, NotificationFacade.class);
addMigration(V20190722150700_LegacyAlertConditionMigration.class);
addAuditEventTypes(EventsAuditEventTypes.class);
registerJacksonSubtype(AggregationEventProcessorConfigEntity.class, AggregationEventProcessorConfigEntity.TYPE_NAME);
registerJacksonSubtype(HttpEventNotificationConfigEntity.class, HttpEventNotificationConfigEntity.TYPE_NAME);
registerJacksonSubtype(EmailEventNotificationConfigEntity.class, EmailEventNotificationConfigEntity.TYPE_NAME);
registerJacksonSubtype(LegacyAlarmCallbackEventNotificationConfigEntity.class, LegacyAlarmCallbackEventNotificationConfigEntity.TYPE_NAME);
addEventProcessor(AggregationEventProcessorConfig.TYPE_NAME, AggregationEventProcessor.class, AggregationEventProcessor.Factory.class, AggregationEventProcessorConfig.class, AggregationEventProcessorParameters.class);
addEventStorageHandler(PersistToStreamsStorageHandler.Config.TYPE_NAME, PersistToStreamsStorageHandler.class, PersistToStreamsStorageHandler.Factory.class, PersistToStreamsStorageHandler.Config.class);
addEventFieldValueProvider(TemplateFieldValueProvider.Config.TYPE_NAME, TemplateFieldValueProvider.class, TemplateFieldValueProvider.Factory.class, TemplateFieldValueProvider.Config.class);
addEventFieldValueProvider(LookupTableFieldValueProvider.Config.TYPE_NAME, LookupTableFieldValueProvider.class, LookupTableFieldValueProvider.Factory.class, LookupTableFieldValueProvider.Config.class);
addSchedulerJob(EventProcessorExecutionJob.TYPE_NAME, EventProcessorExecutionJob.class, EventProcessorExecutionJob.Factory.class, EventProcessorExecutionJob.Config.class, EventProcessorExecutionJob.Data.class);
addSchedulerJob(EventNotificationExecutionJob.TYPE_NAME, EventNotificationExecutionJob.class, EventNotificationExecutionJob.Factory.class, EventNotificationExecutionJob.Config.class, EventNotificationExecutionJob.Data.class);
addNotificationType(EmailEventNotificationConfig.TYPE_NAME, EmailEventNotificationConfig.class, EmailEventNotification.class, EmailEventNotification.Factory.class);
addNotificationType(HTTPEventNotificationConfig.TYPE_NAME, HTTPEventNotificationConfig.class, HTTPEventNotification.class, HTTPEventNotification.Factory.class);
addNotificationType(LegacyAlarmCallbackEventNotificationConfig.TYPE_NAME, LegacyAlarmCallbackEventNotificationConfig.class, LegacyAlarmCallbackEventNotification.class, LegacyAlarmCallbackEventNotification.Factory.class);
addJobSchedulerSchedule(IntervalJobSchedule.TYPE_NAME, IntervalJobSchedule.class);
addJobSchedulerSchedule(OnceJobSchedule.TYPE_NAME, OnceJobSchedule.class);
// Change this if another aggregation search implementation should be used
install(new FactoryModuleBuilder().implement(AggregationSearch.class, PivotAggregationSearch.class).build(AggregationSearch.Factory.class));
}
Aggregations