Java Code Examples for com.google.inject.multibindings.OptionalBinder#newOptionalBinder()
The following examples show how to use
com.google.inject.multibindings.OptionalBinder#newOptionalBinder() .
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: ClusterModule.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override protected void configure() { // TODO move Clock to a more generic module bind(Clock.class).toInstance(Clock.systemUTC()); bind(ClusterService.class).asEagerSingleton(); switch (clusterServiceDao) { default: logger.warn("unknown cluster dao {}: using default instead", clusterServiceDao); // fall through case "default": case "cassandra": bind(ClusterServiceDao.class).to(CassandraClusterServiceDao.class); break; case "zookeeper": logger.info("using zookeeper for cluster registration"); bind(ClusterServiceDao.class).to(ZookeeperClusterServiceDao.class); break; } OptionalBinder.newOptionalBinder(binder(), new TypeLiteral<Set<ClusterServiceListener>>() {}); }
Example 2
Source File: HttpHealthCheckModule.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(HttpHealthCheckServer.class) .asEagerSingleton(); expose(HttpHealthCheckServer.class); OptionalBinder.newOptionalBinder(binder(), ClusterService.class); Multibinder<HttpResource> resourceBinder = Multibinder .newSetBinder(binder(), HttpResource.class, Names.named(HealthCheckServerConfig.NAME_HEALTHCHECK_RESOURCES)); resourceBinder.addBinding().to(CheckPage.class); resourceBinder.addBinding().to(StatusPage.class); }
Example 3
Source File: ModelBinder.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private ModelBinder(ProtectedBinder protectedBinder, TypeLiteral<M> M, TypeLiteral<P> P) { this.binder = Binders.wrap(protectedBinder.publicBinder()); this.M = M; this.P = P; this.metas = Multibinder.newSetBinder(binder, ModelMeta.class); this.serviceBinder = OptionalBinder.newOptionalBinder(binder, ModelService(M, P)); this.queryServiceBinder = OptionalBinder.newOptionalBinder(binder, QueryService(M)); this.updateServiceBinder = OptionalBinder.newOptionalBinder(binder, UpdateService(P)); this.storeBinder = OptionalBinder.newOptionalBinder(binder, ModelStore(M)); binder.install(new OneTime()); binder.install(new PerModel()); }
Example 4
Source File: SessionModelManifest.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void configure() { bindModel(Session.class, SessionDoc.Partial.class, model -> { model.bindService().to(SessionService.class); }); OptionalBinder.newOptionalBinder(publicBinder(), SessionService.class); }
Example 5
Source File: UserModelManifest.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void configure() { bindModel(User.class, UserDoc.Partial.class, model -> { model.bindService().to(UserService.class); }); OptionalBinder.newOptionalBinder(publicBinder(), UserService.class); }
Example 6
Source File: ServerModelManifest.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void configure() { bindAndExpose(ServerStore.class); bindModel(Server.class, ServerDoc.Partial.class, model -> { model.bindStore().to(ServerStore.class); model.bindService().to(ServerService.class); }); OptionalBinder.newOptionalBinder(publicBinder(), ServerService.class); }
Example 7
Source File: MapModelManifest.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void configure() { bindModel(MapDoc.class, model -> { model.bindService().to(MapService.class); }); OptionalBinder.newOptionalBinder(publicBinder(), MapService.class); }
Example 8
Source File: CryptoModule.java From seed with Mozilla Public License 2.0 | 5 votes |
@Override protected void configure() { // Truststore OptionalBinder.newOptionalBinder(binder(), Key.get(KeyStore.class, Names.named(TRUSTSTORE))); if (trustStore != null) { bind(KeyStore.class).annotatedWith(Names.named(TRUSTSTORE)).toInstance(trustStore); } // Keystore(s) for (Entry<String, KeyStore> keyStoreEntry : this.keyStores.entrySet()) { bind(Key.get(KeyStore.class, Names.named(keyStoreEntry.getKey()))).toInstance(keyStoreEntry.getValue()); } // Encryption service(s) for (Entry<Key<EncryptionService>, EncryptionService> entry : this.encryptionServices.entrySet()) { bind(entry.getKey()).toInstance(entry.getValue()); } // Hashing service bind(HashingService.class).to(PBKDF2HashingService.class); // SSL context OptionalBinder.newOptionalBinder(binder(), SSLContext.class); if (sslContext != null) { bind(SSLContext.class).toInstance(sslContext); } // Bind custom X509KeyManager if any if (keyManagerClass != null) { bind(X509KeyManager.class).to(keyManagerClass); } else { bind(X509KeyManager.class).toProvider(Providers.of(null)); } // KeyManager adapters should be injectable keyManagerAdapters.forEach(this::requestInjection); }
Example 9
Source File: SimplePartitionModule.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected void configure() { bind(Partitioner.class).to(SimplePartitioner.class); OptionalBinder.newOptionalBinder(binder(), new TypeLiteral<Set<PartitionListener>>() {}); }
Example 10
Source File: ClusteredPartitionModule.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override protected void configure() { bind(Partitioner.class).to(DynamicPartitioner.class); bindSetOf(ClusterServiceListener.class).addBinding().to(DynamicPartitioner.class); OptionalBinder.newOptionalBinder(binder(), new TypeLiteral<Set<PartitionListener>>() {}); }
Example 11
Source File: Binders.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
default <T> OptionalBinder<T> forOptional(Key<T> key) { return OptionalBinder.newOptionalBinder(forwardedBinder(), key); }