@Override public void configure(Binder binder) { binder.bind(TLSCertificateChecker.class) .annotatedWith(Names.named(DEFAULT_CHECKER_TYPE)) .toInstance(INSTANCE); } }
@Override public void configure(Binder binder) { JsonConfigProvider.bind(binder, "druid.client.https", SSLClientConfig.class); binder.bind(SSLContext.class).toProvider(SSLContextProvider.class); binder.bind(SSLContext.class).annotatedWith(Global.class).toProvider(SSLContextProvider.class); binder.bind(SSLContext.class).annotatedWith(Client.class).toProvider(SSLContextProvider.class); binder.bind(SSLContext.class).annotatedWith(Router.class).toProvider(SSLContextProvider.class); binder.bind(SSLContext.class).annotatedWith(EscalatedGlobal.class).toProvider(SSLContextProvider.class); binder.bind(SSLContext.class).annotatedWith(EscalatedClient.class).toProvider(SSLContextProvider.class); } }
@Override public void configure(Binder binder) { binder.bind(ConfigSource.class) .annotatedWith(ForSystemConfig.class) .toInstance(systemConfig); } }
@Override protected void setup(Binder binder) { binder.bind(Clock.class).toInstance(Clock.systemUTC()); binder.bind(LockService.class).toProvider(LockServiceProvider.class); binder.bind(FieldDependency.class).toProvider(FieldDependencyProvider.class).in(Scopes.SINGLETON); tags.addBinding().toInstance(new Tag().name("admin").description("System related actions").externalDocs(MetadataConfig.centralDocs)); tags.addBinding().toInstance(new Tag().name("query").description("Analyze data").externalDocs(MetadataConfig.centralDocs)); tags.addBinding().toInstance(new Tag().name("materialized-view").description("Materialized view").externalDocs(MetadataConfig.centralDocs)); httpServices.addBinding().to(MaterializedViewHttpService.class); httpServices.addBinding().to(QueryHttpService.class); httpServices.addBinding().to(OptionMethodHttpService.class); binder.bind(SchemaChecker.class).asEagerSingleton(); binder.bind(JSLoggerService.class).to(JSCodeJDBCLoggerService.class); binder.bind(JSCodeJDBCLoggerService.class); binder.bind(RAsyncHttpClient.class) .annotatedWith(Names.named("rakam-client")) .toProvider(() -> RAsyncHttpClient.create(1000 * 60 * 10, "rakam-custom-script")) .in(Scopes.SINGLETON); binder.bind(EventLoopGroup.class) .annotatedWith(ForHttpServer.class) .to(NioEventLoopGroup.class) .in(Scopes.SINGLETON);
bind(InputBuffer.class).to(InputBufferImpl.class); bind(NodeId.class).toProvider(NodeIdProvider.class); bind(Semaphore.class).annotatedWith(Names.named("JournalSignal")).toInstance(new Semaphore(0)); bind(OkHttpClient.class).annotatedWith(Names.named("systemHttpClient")).toProvider(SystemOkHttpClientProvider.class).asEagerSingleton(); bind(ExecutorService.class).annotatedWith(Names.named("proxiedRequestsExecutorService")).toProvider(ProxiedRequestsExecutorService.class).asEagerSingleton();
@Override public void configure(Binder binder) { binder.bind(HostAndPort.class).annotatedWith(named(HTTP_HOST_AND_PORT)).toProvider(SingularityHostAndPortProvider.class).in(Scopes.SINGLETON); binder.bind(LeaderLatch.class).to(SingularityLeaderLatch.class).in(Scopes.SINGLETON); binder.bind(CuratorFramework.class).toProvider(SingularityCuratorProvider.class).in(Scopes.SINGLETON); connectionStateListeners.addBinding().to(SingularityAbort.class).in(Scopes.SINGLETON); leaderLatchListeners.addBinding().to(SingularityLeaderController.class).in(Scopes.SINGLETON); binder.bind(MailTemplateHelpers.class).in(Scopes.SINGLETON); binder.bind(SingularityExceptionNotifier.class).in(Scopes.SINGLETON); binder.bind(LoadBalancerClient.class).to(LoadBalancerClientImpl.class).in(Scopes.SINGLETON); binder.bind(SingularityMailRecordCleaner.class).in(Scopes.SINGLETON); binder.bind(SingularityDropwizardHealthcheck.class).in(Scopes.SINGLETON); binder.bindConstant().annotatedWith(Names.named(SERVER_ID_PROPERTY)).to(UUID.randomUUID().toString()); binder.bind(SingularityManagedScheduledExecutorServiceFactory.class).in(Scopes.SINGLETON); binder.bind(ScheduledExecutorService.class).annotatedWith(HEALTHCHECK_THREADPOOL_NAMED).toProvider(new SingularityManagedScheduledExecutorServiceProvider(configuration.getHealthcheckStartThreads(), configuration.getThreadpoolShutdownDelayInSeconds(), "healthcheck")).in(Scopes.SINGLETON); binder.bind(ScheduledExecutorService.class).annotatedWith(NEW_TASK_THREADPOOL_NAMED).toProvider(new SingularityManagedScheduledExecutorServiceProvider(configuration.getCheckNewTasksScheduledThreads(), configuration.getThreadpoolShutdownDelayInSeconds(), "check-new-task")).in(Scopes.SINGLETON);
@Override public void configure(Binder binder) { binder.bind(IntegrationTestingConfig.class) .toProvider(IntegrationTestingConfigProvider.class) .in(ManageLifecycle.class); JsonConfigProvider.bind(binder, "druid.test.config", IntegrationTestingConfigProvider.class); binder.bind(CuratorConfig.class).to(IntegrationTestingCuratorConfig.class); // Bind DruidNode instance to make Guice happy. This instance is currently unused. binder.bind(DruidNode.class).annotatedWith(Self.class).toInstance( new DruidNode("integration-tests", "localhost", false, 9191, null, null, true, false) ); }
bind(RedissonClient.class).annotatedWith(Names.named(REDIS_CACHE_CLIENT)).toProvider(RedissonCacheClientProvider.class).asEagerSingleton(); bind(CacheManager.class).toProvider(Redis107CacheManagerProvider.class).asEagerSingleton(); } else { bind(RedissonClient.class).annotatedWith(Names.named(REDIS_CACHE_CLIENT)).toProvider(Providers.<RedissonClient>of(null)); bind(CacheManager.class).toProvider(Eh107CacheManagerProvider.class).asEagerSingleton(); resultSetMapperSetBinder.addBinding().to(ImmutableAccountCacheLoader.class).asEagerSingleton(); resultSetMapperSetBinder.addBinding().to(AccountBCDCacheLoader.class).asEagerSingleton(); resultSetMapperSetBinder.addBinding().to(RecordIdCacheLoader.class).asEagerSingleton(); resultSetMapperSetBinder.addBinding().to(AccountRecordIdCacheLoader.class).asEagerSingleton(); resultSetMapperSetBinder.addBinding().to(TenantRecordIdCacheLoader.class).asEagerSingleton();
@Override protected void configureServlets() { bind(TestServlet.class) .annotatedWith(Names.named("foo")) .to(TestServlet.class) .in(Scopes.SINGLETON); bind(TestServlet.class) .annotatedWith(Names.named("bar")) .to(TestServlet.class) .in(Scopes.SINGLETON); serve("/foo/*").with(Key.get(TestServlet.class, Names.named("foo"))); serve("/bar/*").with(Key.get(TestServlet.class, Names.named("bar"))); // TODO: add a filter(..) call and validate it is correct } });
@SuppressWarnings("unchecked") protected void bindFlags(ExtensionContext context) { // Automatically bind all flags in our ExtensionContext to a Named annotation. e.g., binds: // settingsExtension.cloud() to a String annotated with @Named("cloud"), so core classes // may inject '@Named("cloud") String cloud'. for (Method method : context.getClass().getMethods()) { boolean isFlagMethod = method.isAnnotationPresent(Flag.class); if (!isFlagMethod) { continue; } Class returnType = method.getReturnType(); Object flagValue; try { flagValue = method.invoke(context); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Could not get flag value by invoking: " + method.getName(), e); } Preconditions.checkNotNull(flagValue, "Required flag " + method.getName() + " was mull"); bind(returnType).annotatedWith(Names.named(method.getName())).toInstance(flagValue); } } }
@Override public void configure(Binder binder) { Jerseys.addResource(binder, ChatHandlerResource.class); LifecycleModule.register(binder, ChatHandlerResource.class); if (properties.containsKey(MAX_CHAT_REQUESTS_PROPERTY)) { final int maxRequests = Integer.parseInt(properties.getProperty(MAX_CHAT_REQUESTS_PROPERTY)); JettyBindings.addQosFilter(binder, "/druid/worker/v1/chat/*", maxRequests); } Multibinder.newSetBinder(binder, ServletFilterHolder.class).addBinding().to(TaskIdResponseHeaderFilterHolder.class); /** * We bind {@link DruidNode} annotated with {@link RemoteChatHandler} to {@literal @}{@link Self} {@link DruidNode} * so that same Jetty Server is used for querying as well as ingestion. */ binder.bind(DruidNode.class).annotatedWith(RemoteChatHandler.class).to(Key.get(DruidNode.class, Self.class)); binder.bind(ServerConfig.class).annotatedWith(RemoteChatHandler.class).to(Key.get(ServerConfig.class)); binder.bind(TLSServerConfig.class).annotatedWith(RemoteChatHandler.class).to(Key.get(TLSServerConfig.class)); }
protected LinkedBindingBuilder<String> bindEurekaClientConfigNamespace() { return bind(String.class).annotatedWith(Names.named(InternalEurekaClientModule.CLIENT_CONFIG_NAMESPACE_KEY)); }
public static void bindAnnouncer( final Binder binder, final Class<? extends Annotation> annotation, final DiscoverySideEffectsProvider provider ) { binder.bind(DiscoverySideEffectsProvider.Child.class) .annotatedWith(annotation) .toProvider(provider) .in(LazySingleton.class); LifecycleModule.registerKey(binder, Key.get(DiscoverySideEffectsProvider.Child.class, annotation)); }
private void bindPasswordAlgorithms() { MapBinder<String, PasswordAlgorithm> passwordAlgorithms = MapBinder.newMapBinder(binder(), String.class, PasswordAlgorithm.class); passwordAlgorithms.addBinding("sha-1").to(SHA1HashPasswordAlgorithm.class); passwordAlgorithms.addBinding("bcrypt").to(BCryptPasswordAlgorithm.class); bind(PasswordAlgorithm.class).annotatedWith(DefaultPasswordAlgorithm.class).toProvider(DefaultPasswordAlgorithmProvider.class); } }
@Override protected void configure() { // the ObjectMapperProvider requires at least an empty JacksonSubtypes set. // if the multibinder wasn't created that reference will be null, so we force its creation here jacksonSubTypesBinder(); bind(ClassLoader.class).annotatedWith(GraylogClassLoader.class).toInstance(classLoader); bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class).asEagerSingleton(); } }
@Override protected void setup(Binder binder) { binder.bind(JDBCPoolDataSource.class) .annotatedWith(Names.named("async-postgresql")) .toProvider(new JDBCPoolDataSourceProvider(asyncClientConfig)) .in(Scopes.SINGLETON); } };
public static LinkedBindingBuilder<SingularityClientCredentials> bindCredentials(Binder binder) { return binder.bind(SingularityClientCredentials.class).annotatedWith(Names.named(CREDENTIALS_PROPERTY_NAME)); } }
@Override protected void configure() { final Class<? extends MessageOutput> defaultMessageOutputClass = getDefaultMessageOutputClass(BlockingBatchedESOutput.class); LOG.debug("Using default message output class: {}", defaultMessageOutputClass.getCanonicalName()); bind(MessageOutput.class).annotatedWith(DefaultMessageOutput.class).to(defaultMessageOutputClass).in(Scopes.SINGLETON); final MapBinder<String, MessageOutput.Factory<? extends MessageOutput>> outputMapBinder = outputsMapBinder(); installOutput(outputMapBinder, GelfOutput.class, GelfOutput.Factory.class); installOutput(outputMapBinder, LoggingOutput.class, LoggingOutput.Factory.class); }
@Override public void configure(BootstrapBinder binder) { binder.bind(String.class).annotatedWith(EurekaNamespace.class).toInstance("testnamespace."); } })
@Override public void configure(Binder binder) { binder.bind(TLSCertificateChecker.class) .annotatedWith(Names.named(IT_CHECKER_TYPE)) .toInstance(INSTANCE); }