Java Code Examples for com.google.inject.Binder#bind()
The following examples show how to use
com.google.inject.Binder#bind() .
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 File: EnvironmentModule.java From presto with Apache License 2.0 | 6 votes |
@Override public void configure(Binder binder) { binder.bind(PortBinder.class); binder.bind(EnvironmentFactory.class); binder.bind(Standard.class); binder.bind(Hadoop.class); binder.bind(Kerberos.class); binder.bind(KerberosKms.class); binder.bind(Kafka.class); MapBinder<String, EnvironmentProvider> environments = newMapBinder(binder, String.class, EnvironmentProvider.class); Environments.findByBasePackage(BASE_PACKAGE).forEach(clazz -> environments.addBinding(Environments.nameForClass(clazz)).to(clazz)); binder.install(additionalEnvironments); }
Example 2
Source File: TestSmartHomeAlertHandler.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override protected void configure(Binder binder) { super.configure(binder); // generators Binders.bindListToInstancesOf(binder, AlertGenerator.class); binder.bind(CellModemNeededGenerator.class); binder.bind(CellServiceErrorGenerator.class); binder.bind(DeviceLowBatteryGenerator.class); binder.bind(DeviceOfflineGenerator.class); binder.bind(DoorObstructionGenerator.class); binder.bind(HubOfflineGenerator.class); binder.bind(LockJamGenerator.class); // postprocessors Binders.bindListToInstancesOf(binder, AlertPostProcessor.class); binder.bind(ObscureIfHubOfflinePostProcessor.class); binder.bind(OfflineBatteryPostProcessor.class); }
Example 3
Source File: DatabaseModule.java From digdag with Apache License 2.0 | 6 votes |
@Override public void configure(Binder binder) { binder.bind(DatabaseConfig.class).toProvider(DatabaseConfigProvider.class).in(Scopes.SINGLETON); binder.bind(DataSource.class).toProvider(DataSourceProvider.class).in(Scopes.SINGLETON); binder.bind(AutoMigrator.class); binder.bind(DBI.class).toProvider(DbiProvider.class); // don't make this singleton because DBI.registerMapper is called for each StoreManager binder.bind(TransactionManager.class).to(ThreadLocalTransactionManager.class).in(Scopes.SINGLETON); binder.bind(ConfigMapper.class).in(Scopes.SINGLETON); binder.bind(DatabaseMigrator.class).in(Scopes.SINGLETON); binder.bind(ProjectStoreManager.class).to(DatabaseProjectStoreManager.class).in(Scopes.SINGLETON); binder.bind(QueueSettingStoreManager.class).to(DatabaseQueueSettingStoreManager.class).in(Scopes.SINGLETON); binder.bind(SessionStoreManager.class).to(DatabaseSessionStoreManager.class).in(Scopes.SINGLETON); binder.bind(ScheduleStoreManager.class).to(DatabaseScheduleStoreManager.class).in(Scopes.SINGLETON); if (withTaskQueueServer) { binder.bind(DatabaseTaskQueueConfig.class).in(Scopes.SINGLETON); binder.bind(DatabaseTaskQueueServer.class).in(Scopes.SINGLETON); } }
Example 4
Source File: TesterUiModule.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public void configure(Binder binder) { // define all bindings to N4JS-UI here (ui packages) binder.bind(XtextPresentationReconciler.class) .toProvider(() -> n4jsInjector.getInstance(XtextPresentationReconciler.class)); binder.bind(EditorContentExtractor.class) .toProvider(() -> n4jsInjector.getInstance(EditorContentExtractor.class)); binder.bind(IN4JSEclipseCore.class) .toProvider(() -> n4jsInjector.getInstance(IN4JSEclipseCore.class)); binder.bind(IURIEditorOpener.class) .toProvider(() -> n4jsInjector.getInstance(IURIEditorOpener.class)); binder.bind(RunnerFrontEndUI.class) .toProvider(() -> n4jsInjector.getInstance(RunnerFrontEndUI.class)); binder.bind(TestResultsView.class); binder.bind(TestConfigurationConverter.class); }
Example 5
Source File: ProviderDefinition.java From seed with Mozilla Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void apply(Binder binder) { AnnotatedBindingBuilder<T> bind = binder.bind((TypeLiteral<T>) TypeLiteral.get(from)); if (qualifier != null) { LOGGER.debug("Binding {} annotated with {} to provider {}", from.getTypeName(), qualifier, target.getName()); bind.annotatedWith(qualifier).toProvider(target); } else { LOGGER.debug("Binding {} to provider {}", from.getTypeName(), target.getName()); bind.toProvider(target); } }
Example 6
Source File: InternalCommunicationModule.java From presto with Apache License 2.0 | 5 votes |
@Override protected void setup(Binder binder) { InternalCommunicationConfig internalCommunicationConfig = buildConfigObject(InternalCommunicationConfig.class); configBinder(binder).bindConfigGlobalDefaults(HttpClientConfig.class, config -> { config.setKeyStorePath(internalCommunicationConfig.getKeyStorePath()); config.setKeyStorePassword(internalCommunicationConfig.getKeyStorePassword()); config.setTrustStorePath(internalCommunicationConfig.getTrustStorePath()); config.setTrustStorePassword(internalCommunicationConfig.getTrustStorePassword()); }); binder.bind(InternalAuthenticationManager.class); httpClientBinder(binder).bindGlobalFilter(InternalAuthenticationManager.class); }
Example 7
Source File: RestModuleTest.java From seed with Mozilla Public License 2.0 | 5 votes |
@Test public void testBindResources(@Mocked final Binder binder) { underTest.configure(binder); new Verifications() {{ binder.bind(MyResource1.class); binder.bind(MyResource2.class); }}; }
Example 8
Source File: SolidityRuntimeModule.java From solidity-ide with Eclipse Public License 1.0 | 5 votes |
@Override public void configure(Binder binder) { super.configure(binder); binder.bind(String.class).annotatedWith(Names.named(DomainRegistry.DOMAIN_ID)).toInstance(DOMAIN_SOLIDITY); binder.bind(TypesFactory.class).toInstance(TypesFactory.eINSTANCE); binder.bind(SolidityFactory.class).toInstance(SolidityFactory.eINSTANCE); binder.bind(BuiltInDeclarations.class); }
Example 9
Source File: IndexOnlyProjectTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public com.google.inject.Module getServerModule() { ServerModule _serverModule = new ServerModule(); final com.google.inject.Module _function = (Binder it) -> { AnnotatedBindingBuilder<IMultiRootWorkspaceConfigFactory> _bind = it.<IMultiRootWorkspaceConfigFactory>bind(IMultiRootWorkspaceConfigFactory.class); _bind.toInstance(new MultiRootWorkspaceConfigFactory() { @Override public void addProjectsForWorkspaceFolder(final WorkspaceConfig workspaceConfig, final WorkspaceFolder workspaceFolder, final Set<String> existingNames) { String _uri = null; if (workspaceFolder!=null) { _uri=workspaceFolder.getUri(); } boolean _tripleNotEquals = (_uri != null); if (_tripleNotEquals) { URI _uri_1 = this.getUriExtensions().toUri(workspaceFolder.getUri()); String _uniqueProjectName = this.getUniqueProjectName(workspaceFolder.getName(), existingNames); final FileProjectConfig project = new FileProjectConfig(_uri_1, _uniqueProjectName) { @Override public boolean isIndexOnly() { return true; } }; project.addSourceFolder("."); workspaceConfig.addProject(project); } } }); }; return Modules2.mixin(_serverModule, _function); }
Example 10
Source File: SharedStateModule.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.8 */ public void configureProjectByResourceProvider(Binder binder) { if (Activator.isJavaEnabled()) { binder.install(new ProjectByResourceProviderModule()); } else { binder.bind(ProjectByResourceProvider.class); } }
Example 11
Source File: SharedStateContributionRegistryImpl.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected Module getWrappedModule(final Module childModule) { return new Module() { @Override public void configure(Binder binder) { binder.bind(SharedStateContribution.class); binder.install(childModule); } }; }
Example 12
Source File: BaragonServiceModule.java From Baragon with Apache License 2.0 | 4 votes |
@Override public void configure(Binder binder) { binder.install(new BaragonDataModule()); binder.install(new BaragonResourcesModule()); // Healthcheck binder.bind(ZooKeeperHealthcheck.class).in(Scopes.SINGLETON); binder.bind(BaragonExceptionNotifier.class).in(Scopes.SINGLETON); // Managed binder.bind(BaragonExceptionNotifierManaged.class).asEagerSingleton(); binder.bind(BaragonGraphiteReporterManaged.class).asEagerSingleton(); binder.bind(BaragonManaged.class).asEagerSingleton(); // Managers binder.bind(AgentManager.class).in(Scopes.SINGLETON); binder.bind(ElbManager.class).in(Scopes.SINGLETON); binder.bind(RequestManager.class).in(Scopes.SINGLETON); binder.bind(ServiceManager.class).in(Scopes.SINGLETON); binder.bind(StatusManager.class).in(Scopes.SINGLETON); binder.bind(GoogleCloudManager.class).in(Scopes.SINGLETON); // Edge Cache binder.bind(CloudflareEdgeCache.class); binder.bind(CloudflareClient.class); binder.bind(EdgeCache.class).to(getConfiguration().getEdgeCacheConfiguration().getEdgeCache().getEdgeCacheClass()); // Workers binder.bind(BaragonElbSyncWorker.class).in(Scopes.SINGLETON); binder.bind(BaragonRequestWorker.class).in(Scopes.SINGLETON); binder.bind(RequestPurgingWorker.class).in(Scopes.SINGLETON); binder.bind(ClassicLoadBalancer.class); binder.bind(ApplicationLoadBalancer.class); Multibinder<AbstractLatchListener> latchBinder = Multibinder.newSetBinder(binder, AbstractLatchListener.class); latchBinder.addBinding().to(RequestWorkerListener.class).in(Scopes.SINGLETON); latchBinder.addBinding().to(ElbSyncWorkerListener.class).in(Scopes.SINGLETON); latchBinder.addBinding().to(RequestPurgingListener.class).in(Scopes.SINGLETON); }
Example 13
Source File: InstanceMapPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override public void configure(Binder binder) { binder.bind(InstanceMapInputListener.class); }
Example 14
Source File: RaidsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void configure(Binder binder) { binder.bind(RaidsOverlay.class); }
Example 15
Source File: MultiBindingTest.java From che with Eclipse Public License 2.0 | 4 votes |
@Override public void configure(Binder binder) { binder.bind(TestComponent.class); }
Example 16
Source File: AbstractGeneratorFragmentTests.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void configureIXtextProjectConfig(final Binder binder) { AnnotatedBindingBuilder<IXtextProjectConfig> _bind = binder.<IXtextProjectConfig>bind(IXtextProjectConfig.class); AbstractGeneratorFragmentTests.FakeProjectConfig _fakeProjectConfig = new AbstractGeneratorFragmentTests.FakeProjectConfig(); _bind.toInstance(_fakeProjectConfig); }
Example 17
Source File: DefaultXbaseIdeModule.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public void configureClasspathScanner(Binder binder) { binder.bind(ClasspathScanner.class); }
Example 18
Source File: TesterModule.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override public void configure(Binder binder) { if (n4jsInjector != null) { bindListenerForN4jsSingletons(binder); // define all bindings to N4JS here (non-ui packages) binder.bind(ObjectMapper.class) .toProvider(() -> n4jsInjector.getInstance(ObjectMapper.class)); binder.bind(RunnerFrontEnd.class) .toProvider(() -> n4jsInjector.getInstance(RunnerFrontEnd.class)); binder.bind(FileExtensionsRegistry.class) .toProvider(() -> n4jsInjector.getInstance(FileExtensionsRegistry.class)); binder.bind(IN4JSCore.class) .toProvider(() -> n4jsInjector.getInstance(IN4JSCore.class)); binder.bind(ResourceNameComputer.class) .toProvider(() -> n4jsInjector.getInstance(ResourceNameComputer.class)); binder.bind(ContainerTypesHelper.class) .toProvider(() -> n4jsInjector.getInstance(ContainerTypesHelper.class)); binder.bind(N4ExecutableExtensionFactory.class) .toProvider(() -> n4jsInjector.getInstance(N4ExecutableExtensionFactory.class)); binder.bind(RunnerHelper.class) .toProvider(() -> n4jsInjector.getInstance(RunnerHelper.class)); binder.bind(RunnerRegistry.class) .toProvider(() -> n4jsInjector.getInstance(RunnerRegistry.class)); binder.bind(StatusHelper.class) .toProvider(() -> n4jsInjector.getInstance(StatusHelper.class)); binder.bind(ProjectDescriptionLoader.class) .toProvider(() -> n4jsInjector.getInstance(ProjectDescriptionLoader.class)); binder.bind(PackageJsonHelper.class) .toProvider(() -> n4jsInjector.getInstance(PackageJsonHelper.class)); } binder.bind(TesterRegistry.class); binder.bind(TesterEventBus.class); binder.bind(TesterFrontEnd.class); binder.bind(ResourceProvider.class); binder.bind(TestDiscoveryHelper.class); binder.bind(TestCatalogSupplier.class); binder.bind(ServletHolderBuilder.class); binder.bind(DefaultTestTreeTransformer.class); binder.bind(TestFsm.class).to(TestFsmImpl.class); binder.bind(HttpServerManager.class).to(JettyManager.class); binder.bind(TestFsmRegistry.class).to(TestFsmRegistryImpl.class); binder.bind(TesterFacade.class).to(TesterFacadeImpl.class); binder.bind(TestTreeRegistry.class).to(InternalTestTreeRegistry.class); binder.bind(InternalTestTreeRegistry.class).to(TestTreeRegistryImpl.class); binder.bind(TestTreeTransformer.class).to(DefaultTestTreeTransformer.class); binder.bind(UrlDecoderService.class).to(Utf8UrlDecoderService.class); Names.bindProperties(binder, getProperties()); }
Example 19
Source File: TestHttpRemoteTask.java From presto with Apache License 2.0 | 4 votes |
private static HttpRemoteTaskFactory createHttpRemoteTaskFactory(TestingTaskResource testingTaskResource) { Bootstrap app = new Bootstrap( new JsonModule(), new HandleJsonModule(), new Module() { @Override public void configure(Binder binder) { binder.bind(JsonMapper.class); binder.bind(Metadata.class).toInstance(createTestMetadataManager()); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class); } @Provides private HttpRemoteTaskFactory createHttpRemoteTaskFactory( JsonMapper jsonMapper, JsonCodec<TaskStatus> taskStatusCodec, JsonCodec<TaskInfo> taskInfoCodec, JsonCodec<TaskUpdateRequest> taskUpdateRequestCodec) { JaxrsTestingHttpProcessor jaxrsTestingHttpProcessor = new JaxrsTestingHttpProcessor(URI.create("http://fake.invalid/"), testingTaskResource, jsonMapper); TestingHttpClient testingHttpClient = new TestingHttpClient(jaxrsTestingHttpProcessor.setTrace(TRACE_HTTP)); testingTaskResource.setHttpClient(testingHttpClient); return new HttpRemoteTaskFactory( new QueryManagerConfig(), TASK_MANAGER_CONFIG, testingHttpClient, new TestSqlTaskManager.MockLocationFactory(), taskStatusCodec, taskInfoCodec, taskUpdateRequestCodec, new RemoteTaskStats()); } }); Injector injector = app .strictConfig() .doNotInitializeLogging() .quiet() .initialize(); HandleResolver handleResolver = injector.getInstance(HandleResolver.class); handleResolver.addCatalogHandleResolver("test", new TestingHandleResolver()); return injector.getInstance(HttpRemoteTaskFactory.class); }
Example 20
Source File: RaidsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override public void configure(Binder binder) { binder.bind(RaidsOverlay.class); }