@Override public void configure(Binder binder) { binder.bind(CassandraConnectorId.class).toInstance(new CassandraConnectorId(connectorId)); binder.bind(CassandraConnector.class).in(Scopes.SINGLETON); binder.bind(CassandraMetadata.class).in(Scopes.SINGLETON); binder.bind(CassandraSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraTokenSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPartitionManager.class).in(Scopes.SINGLETON); binder.bind(CassandraSessionProperties.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(CassandraClientConfig.class); jsonCodecBinder(binder).bindListJsonCodec(ExtraColumnMetadata.class); }
@Override public void configure(Binder binder) { binder.bind(CassandraConnectorId.class).toInstance(new CassandraConnectorId(connectorId)); binder.bind(CassandraConnector.class).in(Scopes.SINGLETON); binder.bind(CassandraMetadata.class).in(Scopes.SINGLETON); binder.bind(CassandraSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraTokenSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPartitionManager.class).in(Scopes.SINGLETON); binder.bind(CassandraSessionProperties.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(CassandraClientConfig.class); jsonCodecBinder(binder).bindListJsonCodec(ExtraColumnMetadata.class); }
@Override public void configure(Binder binder) { binder.bind(CassandraConnectorId.class).toInstance(new CassandraConnectorId(connectorId)); binder.bind(CassandraConnector.class).in(Scopes.SINGLETON); binder.bind(CassandraMetadata.class).in(Scopes.SINGLETON); binder.bind(CassandraSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraTokenSplitManager.class).in(Scopes.SINGLETON); binder.bind(CassandraRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPageSinkProvider.class).in(Scopes.SINGLETON); binder.bind(CassandraPartitionManager.class).in(Scopes.SINGLETON); binder.bind(CassandraSessionProperties.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(CassandraClientConfig.class); jsonCodecBinder(binder).bindListJsonCodec(ExtraColumnMetadata.class); }
JsonCodecBinder.jsonCodecBinder(binder).bindJsonCodec(ServiceDescriptorsRepresentation.class); JsonCodecBinder.jsonCodecBinder(binder).bindJsonCodec(ExpectedSlotStatus.class); JsonCodecBinder.jsonCodecBinder(binder).bindListJsonCodec(ServiceDescriptor.class);
@Override protected void setup(Binder binder) { configBinder(binder).bindConfig(DiscoveryConfig.class); jaxrsBinder(binder).bind(ServiceResource.class); discoveryBinder(binder).bindHttpAnnouncement("discovery"); jsonCodecBinder(binder).bindJsonCodec(Service.class); jsonCodecBinder(binder).bindListJsonCodec(Service.class); binder.bind(ServiceSelector.class).to(DiscoveryServiceSelector.class); binder.bind(StaticStore.class).to(EmptyStaticStore.class); jaxrsBinder(binder).bind(DynamicAnnouncementResource.class); binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(Scopes.SINGLETON); binder.install(new ReplicatedStoreModule("dynamic", ForDynamicStore.class, InMemoryStore.class)); }
@Override protected void setup(Binder binder) { if (!buildConfigObject(EmbeddedDiscoveryConfig.class).isEnabled()) { return; } configBinder(binder).bindConfig(DiscoveryConfig.class); jaxrsBinder(binder).bind(ServiceResource.class); discoveryBinder(binder).bindHttpAnnouncement("discovery"); jsonCodecBinder(binder).bindJsonCodec(Service.class); jsonCodecBinder(binder).bindListJsonCodec(Service.class); binder.bind(ServiceSelector.class).to(DiscoveryServiceSelector.class); binder.bind(StaticStore.class).to(EmptyStaticStore.class); jaxrsBinder(binder).bind(DynamicAnnouncementResource.class); binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(Scopes.SINGLETON); binder.install(new ReplicatedStoreModule("dynamic", ForDynamicStore.class, InMemoryStore.class)); }
@Override public void configure(Binder binder) { configBinder(binder).bindConfig(DiscoveryConfig.class); jaxrsBinder(binder).bind(ServiceResource.class); discoveryBinder(binder).bindHttpAnnouncement("discovery"); jsonCodecBinder(binder).bindJsonCodec(Service.class); jsonCodecBinder(binder).bindListJsonCodec(Service.class); binder.bind(ServiceSelector.class).to(DiscoveryServiceSelector.class); // dynamic announcements jaxrsBinder(binder).bind(DynamicAnnouncementResource.class); binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(Scopes.SINGLETON); binder.install(new ReplicatedStoreModule("dynamic", ForDynamicStore.class, InMemoryStore.class)); // static announcements jaxrsBinder(binder).bind(StaticAnnouncementResource.class); binder.bind(StaticStore.class).to(ReplicatedStaticStore.class).in(Scopes.SINGLETON); binder.install(new ReplicatedStoreModule("static", ForStaticStore.class, PersistentStore.class)); configBinder(binder).bindConfig(PersistentStoreConfig.class, "static"); } }
public void configure(Binder binder) { JsonCodecBinder codecBinder = jsonCodecBinder(binder); codecBinder.bindJsonCodec(Person.class); codecBinder.bindListJsonCodec(Person.class); codecBinder.bindMapJsonCodec(String.class, Person.class); } });
@Test public void test() throws Exception { Injector injector = Guice.createInjector(new JsonModule(), binder -> { JsonCodecBinder codecBinder = jsonCodecBinder(binder); codecBinder.bindJsonCodec(Person.class); codecBinder.bindListJsonCodec(Person.class); codecBinder.bindMapJsonCodec(String.class, Person.class); }); injector.injectMembers(this); assertNotNull(personJsonCodec); assertNotNull(personListJsonCodec); assertNotNull(personMapJsonCodec); Person.validatePersonJsonCodec(personJsonCodec); Person.validatePersonListJsonCodec(personListJsonCodec); Person.validatePersonMapJsonCodec(personMapJsonCodec); } }
@Test public void test() throws Exception { Injector injector = Guice.createInjector(new JsonModule(), binder -> { JsonCodecBinder codecBinder = jsonCodecBinder(binder); codecBinder.bindJsonCodec(Person.class); codecBinder.bindListJsonCodec(Person.class); codecBinder.bindMapJsonCodec(String.class, Person.class); }); injector.injectMembers(this); assertNotNull(personJsonCodec); assertNotNull(personListJsonCodec); assertNotNull(personMapJsonCodec); Person.validatePersonJsonCodec(personJsonCodec); Person.validatePersonListJsonCodec(personListJsonCodec); Person.validatePersonMapJsonCodec(personMapJsonCodec); } }