@Override protected void configure() { requireBinding(SwaggerConfig.class); // Create empty multibinder in case no ModelConverter bindings exist Multibinder<ModelConverter> swaggerModelConverterBinder = Multibinder.newSetBinder( binder(), ModelConverter.class); bind(SwaggerApiResource.class); bind(SwaggerUiResource.class); bind(ApiDeclarationProvider.class); bind(ResourceListingProvider.class); bind(JaxrsApiReader.class).to(DefaultJaxrsApiReader.class); bind(JaxrsScanner.class).to(SwaggerGuiceJaxrsScanner.class); bind(SwaggerLifecycleHook.class).asEagerSingleton(); install(MultibindingsScanner.asModule()); }
@Override protected void configure() { Multibinder.newSetBinder(binder(), Module.class, clientBindingAnnotation); Multibinder.newSetBinder(binder(), SerializationFeatureFlag.class, clientBindingAnnotation); Multibinder.newSetBinder(binder(), DeserializationFeatureFlag.class, clientBindingAnnotation); Multibinder.newSetBinder(binder(), JsonGeneratorFeatureFlag.class, clientBindingAnnotation); Multibinder.newSetBinder(binder(), JsonParserFeatureFlag.class, clientBindingAnnotation); Multibinder.newSetBinder(binder(), MapperFeatureFlag.class, clientBindingAnnotation); /** * MultibindingsScanner will scan all modules for methods with the annotations @ProvidesIntoMap, * @ProvidesIntoSet, and @ProvidesIntoOptional. */ install(MultibindingsScanner.asModule()); install(AnnotatedJacksonPrivateModule.with(clientBindingAnnotation)); }
@Override protected void configure() { requireBinding(ServiceMetadata.class); requireBinding(UriInfo.class); bind(AvailabilityResource.class).to(AvailabilityResourceImpl.class); bind(HealthResource.class).to(HealthResourceImpl.class); bind(DependenciesResource.class).to(DependenciesResourceImpl.class); bind(DiagnosticResource.class).to(DiagnosticResourceImpl.class); bind(VersionResource.class).to(VersionResourceImpl.class); bind(HealthChecker.class); //This is to provide a default binding for HealthDependency, // so that services with no HealthDependency bindings can start Multibinder<HealthDependency> healthDependencyModuleBinder = Multibinder.newSetBinder(binder(), HealthDependency.class); Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class); jacksonModuleBinder.addBinding().to(Jdk8Module.class); jacksonModuleBinder.addBinding().to(JavaTimeModule.class); install(MultibindingsScanner.asModule()); }
@Override protected void configure() { // Empty multibindings for dependencies Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class); Multibinder<SerializationFeatureFlag> serializationFeatureBinder = Multibinder .newSetBinder(binder(), SerializationFeatureFlag.class); Multibinder<DeserializationFeatureFlag> deserializationFeatureBinder = Multibinder .newSetBinder(binder(), DeserializationFeatureFlag.class); Multibinder<JsonGeneratorFeatureFlag> jsonGeneratorFeatureBinder = Multibinder .newSetBinder(binder(), JsonGeneratorFeatureFlag.class); Multibinder<JsonParserFeatureFlag> jsonParserFeatureBinder = Multibinder .newSetBinder(binder(), JsonParserFeatureFlag.class); Multibinder<MapperFeatureFlag> mapperFeatureBinder = Multibinder .newSetBinder(binder(), MapperFeatureFlag.class); /** * MultibindingsScanner will scan all modules for methods with the annotations @ProvidesIntoMap, * @ProvidesIntoSet, and @ProvidesIntoOptional. */ install(MultibindingsScanner.asModule()); bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class).asEagerSingleton(); }
@Override protected void configure() { Multibinder<ModelConverter> swaggerModelConverterBinder = Multibinder.newSetBinder(binder(), ModelConverter.class); swaggerModelConverterBinder.addBinding().to(SwaggerAvroModelConverter.class); install(MultibindingsScanner.asModule()); }
@Override protected void configure() { Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class); jacksonModuleBinder.addBinding().to(AvroJacksonModule.class); install(MultibindingsScanner.asModule()); }
protected void configure() { install(MultibindingsScanner.asModule()); install(new ServletModule()); requireBinding(Key.get(new TypeLiteral<Set<ConnectorFactory>>() {})); bind(ServletHolder.class) .toProvider(ServletHolderProvider.class) .asEagerSingleton(); bind(Handler.class) .toProvider(ServletContextHandlerProvider.class) .asEagerSingleton(); bind(Server.class) .toProvider(JettyServerProvider.class) .asEagerSingleton(); bind(ResourceConfig.class) .toProvider(resourceConfigProvider()) .asEagerSingleton(); bind(HttpConfiguration.class) .annotatedWith(BaseConfiguration.class) .toProvider(HttpConfigurationProvider.class) .asEagerSingleton(); }
@Override protected void configure() { install(MultibindingsScanner.asModule()); install(new DockerClientModule()); install(new PostModule()); bind(HvalspikController.class).to(HvalspikControllerImpl.class).in(Singleton.class); bind(ExecutorService.class).toProvider(ExecutorProvider.class).in(Singleton.class); MapBinder.newMapBinder(binder(), String.class, Container.class); Multibinder.newSetBinder(binder(), Network.class); }
@Override protected void configure() { install(MultibindingsScanner.asModule()); requestInjection(container); requestInjection(container.getImageSource()); MapBinder<String, Container> mapbinder = MapBinder.newMapBinder(binder(), String.class, Container.class); mapbinder.addBinding(bindingName).toInstance(container); }
@Override public void configure(Binder binder) { binder.install(MultibindingsScanner.asModule()); Multibinder<SystemTable> globalTableBinder = Multibinder.newSetBinder(binder, SystemTable.class); globalTableBinder.addBinding().to(NodeSystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(QuerySystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(TaskSystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(CatalogSystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(TablePropertiesSystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(TransactionsSystemTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(AttributeJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(CatalogJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(ColumnJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(ProcedureColumnJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(ProcedureJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(PseudoColumnJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(SchemaJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(SuperTableJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(SuperTypeJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(TableJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(TableTypeJdbcTable.class).in(Scopes.SINGLETON); globalTableBinder.addBinding().to(UdtJdbcTable.class).in(Scopes.SINGLETON); Multibinder.newSetBinder(binder, Procedure.class); binder.bind(KillQueryProcedure.class).in(Scopes.SINGLETON); binder.bind(GlobalSystemConnectorFactory.class).in(Scopes.SINGLETON); binder.bind(SystemConnectorRegistrar.class).asEagerSingleton(); }
@Override protected void configure() { Multibinder.newSetBinder(binder(), ConfigurationSource.class); install(MultibindingsScanner.asModule()); }
public static void main(String[] args) throws IOException, MetaDataManagerException, InterruptedException { m_logger.info("Starting KafkaAvailability Tool"); Options options = new Options(); options.addOption("r", "run", true, "Number of runs. Don't use this argument if you want to run infinitely."); options.addOption("s", "sleep", true, "Time (in milliseconds) to sleep between each run. Default is 30000"); options.addOption("c", "cluster", true, "Cluster name. will pull from here if appProperties is null"); options.addOption("p", "keyStorePassword", true, "Password to load KeyStore file, which is uesed to connect to cluster's secured public IP"); CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine line; try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException exp) { // oops, something went wrong m_logger.error("Parsing failed. Reason: " + exp.getMessage()); formatter.printHelp("KafkaAvailability", options); throw new RuntimeException("Failed to parse app variables"); } Injector parent = Guice.createInjector(new AppModule(line, "reporterProperties.json", "appProperties.json", "metadatamanagerProperties.json")); ImmutableSet<Module> allGuiceModules = ImmutableSet.<Module>builder() .add(MultibindingsScanner.asModule()) .add(parent.getInstance(ReportersModule.class)) .add(parent.getInstance(MonitorTasksModule.class)) .addAll(ModuleScanner.getModulesFromDependencies()) .build(); //Parent injector to process command line arguments and json files Injector injector = parent.createChildInjector(allGuiceModules.toArray(new Module[allGuiceModules.size()])); appProperties = injector.getInstance(AppProperties.class); metaDataProperties = injector.getInstance(MetaDataManagerProperties.class); final CuratorManager curatorManager = injector.getInstance(CuratorManager.class); final MonitorTaskFactory monitorTaskFactory = injector.getInstance(MonitorTaskFactory.class); final ScheduledReporterCollector reporterCollector = injector.getInstance(ScheduledReporterCollector.class); reporterCollector.start(); final HeartBeat heartBeat = injector.getInstance(HeartBeat.class); MDC.put("cluster", appProperties.environmentName); MDC.put("computerName", computerName); if (line.hasOption("sleep")) { m_sleepTime = Integer.parseInt(line.getOptionValue("sleep")); } heartBeat.start(); int howManyRuns; if (line.hasOption("run")) { howManyRuns = Integer.parseInt(line.getOptionValue("run")); for (int i = 0; i < howManyRuns; i++) { waitForChanges(curatorManager); runOnce(monitorTaskFactory, reporterCollector); Thread.sleep(m_sleepTime); } } else { while (true) { waitForChanges(curatorManager); runOnce(monitorTaskFactory, reporterCollector); Thread.sleep(m_sleepTime); } } reporterCollector.report(); reporterCollector.stop(); //used to run shutdown hooks before the program quits. The shutdown hooks (if properly set up) take care of doing all necessary shutdown ceremonies such as closing files, releasing resources etc. System.exit(0); if (heartBeat != null) { heartBeat.stop(); } }