Java Code Examples for com.google.inject.Provides
The following examples show how to use
com.google.inject.Provides. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: presto Source File: KuduModule.java License: Apache License 2.0 | 6 votes |
@Singleton @Provides KuduClientSession createKuduClientSession(KuduClientConfig config) { requireNonNull(config, "config is null"); KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder(config.getMasterAddresses()); builder.defaultAdminOperationTimeoutMs(config.getDefaultAdminOperationTimeout().toMillis()); builder.defaultOperationTimeoutMs(config.getDefaultOperationTimeout().toMillis()); builder.defaultSocketReadTimeoutMs(config.getDefaultSocketReadTimeout().toMillis()); if (config.isDisableStatistics()) { builder.disableStatistics(); } KuduClient client = builder.build(); SchemaEmulation strategy; if (config.isSchemaEmulationEnabled()) { strategy = new SchemaEmulationByTableNameConvention(config.getSchemaEmulationPrefix()); } else { strategy = new NoSchemaEmulation(); } return new KuduClientSession(client, strategy); }
Example 2
Source Project: presto Source File: BackupModule.java License: Apache License 2.0 | 6 votes |
@Provides @Singleton private static Optional<BackupStore> createBackupStore( @Nullable BackupStore store, LifeCycleManager lifeCycleManager, MBeanExporter exporter, RaptorConnectorId connectorId, BackupConfig config) { if (store == null) { return Optional.empty(); } BackupStore proxy = new TimeoutBackupStore( store, connectorId.toString(), config.getTimeout(), config.getTimeoutThreads()); lifeCycleManager.addInstance(proxy); BackupStore managed = new ManagedBackupStore(proxy); exporter.exportWithGeneratedName(managed, BackupStore.class, connectorId.toString()); return Optional.of(managed); }
Example 3
Source Project: presto Source File: AuthenticationModules.java License: Apache License 2.0 | 6 votes |
public static Module kerberosImpersonatingHdfsAuthenticationModule() { return new Module() { @Override public void configure(Binder binder) { binder.bind(HdfsAuthentication.class) .to(ImpersonatingHdfsAuthentication.class) .in(SINGLETON); configBinder(binder).bindConfig(HdfsKerberosConfig.class); } @Inject @Provides @Singleton @ForHdfs HadoopAuthentication createHadoopAuthentication(HdfsKerberosConfig config, HdfsConfigurationInitializer updater) { String principal = config.getHdfsPrestoPrincipal(); String keytabLocation = config.getHdfsPrestoKeytab(); return createCachingKerberosHadoopAuthentication(principal, keytabLocation, updater); } }; }
Example 4
Source Project: dynein Source File: SchedulerModule.java License: Apache License 2.0 | 6 votes |
@Provides @Singleton public HeartbeatManager provideHeartBeat(EventBus eventBus, Clock clock) { HeartbeatManager heartbeatManager = new HeartbeatManager( new ConcurrentHashMap<>(), MoreExecutors.getExitingScheduledExecutorService( (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool( 1, new ThreadFactoryBuilder().setNameFormat("heartbeat-manager-%d").build())), eventBus, clock, heartbeatConfiguration); eventBus.register(heartbeatManager); return heartbeatManager; }
Example 5
Source Project: presto Source File: WarningCollectorModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public WarningCollectorFactory createWarningCollectorFactory(WarningCollectorConfig config) { requireNonNull(config, "config is null"); return () -> new DefaultWarningCollector(config); }
Example 6
Source Project: arcusplatform Source File: PreviewModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public ExecutorService previewImageExecutor(PreviewConfig config) { return new ThreadPoolBuilder() .withBlockingBacklog() .withMaxPoolSize(config.getStorageAzureMaxThreads()) .withKeepAliveMs(config.getStorageAzureKeepAliveMs()) .withNameFormat("preview-image-writer-%d") .withMetrics("preview.azure") .build(); }
Example 7
Source Project: presto Source File: MongoClientModule.java License: Apache License 2.0 | 5 votes |
@Singleton @Provides public static MongoSession createMongoSession(TypeManager typeManager, MongoClientConfig config) { requireNonNull(config, "config is null"); MongoClientOptions.Builder options = MongoClientOptions.builder(); options.connectionsPerHost(config.getConnectionsPerHost()) .connectTimeout(config.getConnectionTimeout()) .socketTimeout(config.getSocketTimeout()) .socketKeepAlive(config.getSocketKeepAlive()) .sslEnabled(config.getSslEnabled()) .maxWaitTime(config.getMaxWaitTime()) .minConnectionsPerHost(config.getMinConnectionsPerHost()) .readPreference(config.getReadPreference().getReadPreference()) .writeConcern(config.getWriteConcern().getWriteConcern()); if (config.getRequiredReplicaSetName() != null) { options.requiredReplicaSetName(config.getRequiredReplicaSetName()); } MongoClient client = new MongoClient(config.getSeeds(), config.getCredentials(), options.build()); return new MongoSession( typeManager, client, config); }
Example 8
Source Project: reactor-guice Source File: Module.java License: Apache License 2.0 | 5 votes |
@Singleton @Provides public Gson gson () { return new GsonBuilder() .serializeNulls() .setDateFormat("yyyy-MM-dd HH:mm:ss") .setLongSerializationPolicy(LongSerializationPolicy.STRING) .create(); }
Example 9
Source Project: presto Source File: TestingH2JdbcModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton @ForBaseJdbc public ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider) { return new DriverConnectionFactory(new Driver(), config, credentialProvider); }
Example 10
Source Project: arcusplatform Source File: DriverServicesModule.java License: Apache License 2.0 | 5 votes |
@Provides @Named(GroovyDriverModule.NAME_GROOVY_DRIVER_DIRECTORIES) public Set<URL> groovyDriverUrls(DriverConfig config) throws MalformedURLException { Set<URL> urls = new LinkedHashSet<>(); urls.add(new File(config.evaluateAbsoluteDriverDirectory()).toURI().toURL()); return urls; }
Example 11
Source Project: realworld-serverless-application Source File: ApplicationModule.java License: Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides SsmParameterCachingClient ssmParameterCachingClient() { String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage")); return new SsmParameterCachingClient(SsmClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .build(), Duration.ofMinutes(5), path); }
Example 12
Source Project: realworld-serverless-application Source File: ApplicationModule.java License: Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides AWSServerlessApplicationRepository AWSServerlessApplicationRepository(final SsmParameterCachingClient ssm, final CognitoUserManager cognitoUserManager) { String endpoint = ssm.getAsString("apigateway/ApplicationsApi/Endpoint"); return new AWSServerlessApplicationRepositoryRecordingClient(AWSServerlessApplicationRepository.builder() .endpoint(endpoint) .signer(new CognitoAuthorizerImpl(cognitoUserManager)) .build()); }
Example 13
Source Project: presto Source File: H2ResourceGroupsModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton @ForEnvironment public String getEnvironment(ResourceGroupConfigurationManagerContext context) { return context.getEnvironment(); }
Example 14
Source Project: arcusplatform Source File: SubsystemModule.java License: Apache License 2.0 | 5 votes |
@Provides public Scheduler scheduler(SubsystemConfig config) { ScheduledExecutorService executor = Executors .newScheduledThreadPool( config.getSchedulerThreads(), ThreadPoolBuilder .defaultFactoryBuilder() .setNameFormat("subsystem-scheduler-%d") .build() ); return new ExecutorScheduler(executor); }
Example 15
Source Project: presto Source File: CachingHiveMetastoreModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public HiveMetastore createCachingHiveMetastore( @ForCachingHiveMetastore HiveMetastore delegate, @ForCachingHiveMetastore Executor executor, CachingHiveMetastoreConfig config, Optional<HiveMetastoreDecorator> hiveMetastoreDecorator) { HiveMetastore decoratedDelegate = hiveMetastoreDecorator.map(decorator -> decorator.decorate(delegate)) .orElse(delegate); return cachingHiveMetastore(decoratedDelegate, executor, config); }
Example 16
Source Project: arcusplatform Source File: BridgeConfigModule.java License: Apache License 2.0 | 5 votes |
@Provides @Named("tcpChannelOptions") public Map<ChannelOption<?>, Object> provideTcpChannelOptions(BridgeServerConfig serverConfig) { return ImmutableMap.of( ChannelOption.TCP_NODELAY, true, ChannelOption.AUTO_CLOSE, true, ChannelOption.SO_KEEPALIVE, serverConfig.isSoKeepAlive() ); }
Example 17
Source Project: arcusplatform Source File: PreviewModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public PreviewStorage provideSnapshotStorage(PreviewConfig config) { switch (config.getStorageType()) { case PreviewConfig.PREVIEWS_STORAGE_TYPE_FS: return new PreviewStorageFile(config.getStorageFsBasePath()); case PreviewConfig.PREVIEWS_STORAGE_TYPE_AZURE: return new PreviewStorageAzure(config.getStorageAzureAccounts(),config.getStorageAzureContainer(),previewImageExecutor(config)); case PreviewConfig.PREVIEWS_STORAGE_TYPE_NULL: return new PreviewStorageNull(); default: throw new RuntimeException("unknown video storage type: " + config.getStorageType()); } }
Example 18
Source Project: realworld-serverless-application Source File: ApplicationModule.java License: Apache License 2.0 | 5 votes |
@Singleton @Inject @Provides SsmParameterCachingClient ssmParameterCachingClient() { String path = String.format("/applications/apprepo/%s/", System.getProperty("integtests.stage")); return new SsmParameterCachingClient(SsmClient.builder() .httpClientBuilder(UrlConnectionHttpClient.builder()) .build(), Duration.ofMinutes(5), path); }
Example 19
Source Project: presto Source File: RaptorModule.java License: Apache License 2.0 | 5 votes |
@ForMetadata @Singleton @Provides public IDBI createDBI(@ForMetadata ConnectionFactory connectionFactory, TypeManager typeManager) { DBI dbi = new DBI(connectionFactory); dbi.registerMapper(new TableColumn.Mapper(typeManager)); dbi.registerMapper(new Distribution.Mapper(typeManager)); createTablesWithRetry(dbi); return dbi; }
Example 20
Source Project: arcusplatform Source File: VoiceModule.java License: Apache License 2.0 | 5 votes |
@Provides @Named(VoiceConfig.NAME_TIMEOUT_TIMER) @Singleton public HashedWheelTimer timeoutTimer() { return new HashedWheelTimer(new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat("voice-execute-timeout-%d") .setUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler(LoggerFactory.getLogger(CommandExecutor.class))) .build()); }
Example 21
Source Project: presto Source File: BigQueryConnectorModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public BigQueryClient provideBigQueryClient(BigQueryConfig config, HeaderProvider headerProvider, BigQueryCredentialsSupplier bigQueryCredentialsSupplier) { String billingProjectId = calculateBillingProjectId(config.getParentProjectId(), bigQueryCredentialsSupplier.getCredentials()); BigQueryOptions.Builder options = BigQueryOptions.newBuilder() .setHeaderProvider(headerProvider) .setProjectId(billingProjectId); // set credentials of provided bigQueryCredentialsSupplier.getCredentials().ifPresent(options::setCredentials); return new BigQueryClient(options.build().getService(), config); }
Example 22
Source Project: presto Source File: ServerSecurityModule.java License: Apache License 2.0 | 5 votes |
@Provides public List<Authenticator> getAuthenticatorList(SecurityConfig config, Map<String, Authenticator> authenticators) { return authenticationTypes(config).stream() .map(type -> { Authenticator authenticator = authenticators.get(type); if (authenticator == null) { throw new RuntimeException("Unknown authenticator type: " + type); } return authenticator; }) .collect(toImmutableList()); }
Example 23
Source Project: arcusplatform Source File: TemplateModule.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton TemplateService templateService(){ HandlebarsTemplateService hbTemplateService = new HandlebarsTemplateService(templatePath, cacheSize); if(helpers!=null){ hbTemplateService.registerHelpers(helpers); } return hbTemplateService; }
Example 24
Source Project: arcusplatform Source File: SandboxNotificationServicesModule.java License: Apache License 2.0 | 5 votes |
@Provides @Named("notifications.executor") public ExecutorService getNotificationsExecutor(NotificationServiceConfig config) { return new ThreadPoolBuilder() .withMaxPoolSize(config.getMaxThreads()) .withKeepAliveMs(config.getThreadKeepAliveMs()) .withNameFormat("notification-dispatcher-%d") .withBlockingBacklog() .withMetrics("service.notifications") .build(); }
Example 25
Source Project: arcusplatform Source File: GroovyDriverTestCase.java License: Apache License 2.0 | 5 votes |
@Provides @Singleton public GroovyScriptEngine scriptEngine(Set<CompilationCustomizer> customizers) { GroovyScriptEngine engine = scriptEngine(); for(CompilationCustomizer customizer: customizers) { engine.getConfig().addCompilationCustomizers(customizer); } engine.getConfig().setScriptExtensions(ImmutableSet.of("driver", "capability", "groovy")); return engine; }
Example 26
Source Project: presto Source File: HiveModule.java License: Apache License 2.0 | 5 votes |
@ForHiveTransactionHeartbeats @Singleton @Provides public ScheduledExecutorService createHiveTransactionHeartbeatExecutor(CatalogName catalogName, HiveConfig hiveConfig) { return newScheduledThreadPool( hiveConfig.getHiveTransactionHeartbeatThreads(), daemonThreadsNamed("hive-heartbeat-" + catalogName + "-%s")); }
Example 27
Source Project: arcusplatform Source File: PlatformServicesModule.java License: Apache License 2.0 | 4 votes |
@Provides @Named(PopulationService.PROP_THREADPOOL) public Executor populationExecutor() { return executor; }
Example 28
Source Project: presto Source File: AlluxioMetastoreModule.java License: Apache License 2.0 | 4 votes |
@Provides public TableMasterClient provideCatalogMasterClient(AlluxioHiveMetastoreConfig config) { return createCatalogMasterClient(config); }
Example 29
Source Project: arcusplatform Source File: ClusterModule.java License: Apache License 2.0 | 4 votes |
@Provides @Named(ClusterService.NAME_EXECUTOR) @Singleton public ScheduledExecutorService clusterServiceHeartbeatExecutor() { return ThreadPoolBuilder.newSingleThreadedScheduler("cluster-heartbeat-executor"); }
Example 30
Source Project: plugins Source File: StealingArtefactsPlugin.java License: GNU General Public License v3.0 | 4 votes |
@Provides StealingArtefactsConfig getStealingArtefactsConfig(ConfigManager configManager) { return configManager.getConfig(StealingArtefactsConfig.class); }