Search in sources :

Example 31 with FactoryModuleBuilder

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;
}
Also used : Injector(com.google.inject.Injector) FactoryModule(com.google.gerrit.extensions.config.FactoryModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate)

Example 32 with FactoryModuleBuilder

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));
}
Also used : URLConnectionFactory(net.rdrei.android.scdl2.api.URLConnectionFactory) DownloadPreferencesDelegateFactory(net.rdrei.android.scdl2.ui.DownloadPreferencesDelegateFactory) PinningTrustManager(org.thoughtcrime.ssl.pinning.PinningTrustManager) URLWrapperFactory(net.rdrei.android.scdl2.api.URLWrapperFactory) PreferenceManagerWrapperFactory(net.rdrei.android.scdl2.PreferenceManagerWrapperFactory) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) TrackDownloaderFactory(net.rdrei.android.scdl2.TrackDownloaderFactory) DownloadManager(android.app.DownloadManager) IabHelper(com.android.vending.billing.IabHelper) PackageManager(android.content.pm.PackageManager) ActionBar(android.app.ActionBar)

Example 33 with FactoryModuleBuilder

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));
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder)

Example 34 with FactoryModuleBuilder

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));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) LoggingPreferences(org.openqa.selenium.logging.LoggingPreferences) RunDetailsArtifactsPageFactory(io.blueocean.ath.factory.RunDetailsArtifactsPageFactory) Properties(java.util.Properties) BranchPageFactory(io.blueocean.ath.factory.BranchPageFactory) URI(java.net.URI) URL(java.net.URL) FirefoxOptions(org.openqa.selenium.firefox.FirefoxOptions) PullRequestsPageFactory(io.blueocean.ath.factory.PullRequestsPageFactory) FreestyleJobFactory(io.blueocean.ath.factory.FreestyleJobFactory) MutableCapabilities(org.openqa.selenium.MutableCapabilities) ClassicPipelineFactory(io.blueocean.ath.factory.ClassicPipelineFactory) RunDetailsPipelinePageFactory(io.blueocean.ath.factory.RunDetailsPipelinePageFactory) MultiBranchPipelineFactory(io.blueocean.ath.factory.MultiBranchPipelineFactory) RunDetailsTestsPageFactory(io.blueocean.ath.factory.RunDetailsTestsPageFactory) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) JenkinsServer(com.offbytwo.jenkins.JenkinsServer) Dimension(org.openqa.selenium.Dimension) FileInputStream(java.io.FileInputStream) Augmenter(org.openqa.selenium.remote.Augmenter) ActivityPageFactory(io.blueocean.ath.factory.ActivityPageFactory) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) File(java.io.File)

Example 35 with FactoryModuleBuilder

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));
}
Also used : EventStorageHandlerEngine(org.graylog.events.processor.storage.EventStorageHandlerEngine) AggregationEventProcessor(org.graylog.events.processor.aggregation.AggregationEventProcessor) EventProcessorEngine(org.graylog.events.processor.EventProcessorEngine) EventFieldSpecEngine(org.graylog.events.fields.EventFieldSpecEngine) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) EventIndexer(org.graylog.events.indices.EventIndexer) EventProcessorExecutionMetrics(org.graylog.events.processor.EventProcessorExecutionMetrics) EventNotificationExecutionMetrics(org.graylog.events.notifications.EventNotificationExecutionMetrics) EventNotificationExecutionJob(org.graylog.events.notifications.EventNotificationExecutionJob) LegacyAlarmCallbackEventNotification(org.graylog.events.legacy.LegacyAlarmCallbackEventNotification) PersistToStreamsStorageHandler(org.graylog.events.processor.storage.PersistToStreamsStorageHandler) TemplateFieldValueProvider(org.graylog.events.fields.providers.TemplateFieldValueProvider) NotificationGracePeriodService(org.graylog.events.notifications.NotificationGracePeriodService) LookupTableFieldValueProvider(org.graylog.events.fields.providers.LookupTableFieldValueProvider) HTTPEventNotification(org.graylog.events.notifications.types.HTTPEventNotification) EmailEventNotification(org.graylog.events.notifications.types.EmailEventNotification) EventProcessorExecutionJob(org.graylog.events.processor.EventProcessorExecutionJob)

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