@Override public void configure(Binder binder) { binder.bind(KafkaConnector.class).in(Scopes.SINGLETON); binder.bind(KafkaMetadata.class).in(Scopes.SINGLETON); binder.bind(KafkaSplitManager.class).in(Scopes.SINGLETON); binder.bind(KafkaRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(KafkaSimpleConsumerManager.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(KafkaConnectorConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(KafkaTopicDescription.class); binder.install(new DecoderModule()); }
@Override public void configure(Binder binder) { binder.bind(RedisConnector.class).in(Scopes.SINGLETON); binder.bind(RedisMetadata.class).in(Scopes.SINGLETON); binder.bind(RedisSplitManager.class).in(Scopes.SINGLETON); binder.bind(RedisRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(RedisJedisManager.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(RedisConnectorConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(RedisTableDescription.class); binder.install(new RedisDecoderModule()); }
@Override public void configure(Binder binder) { binder.bind(ElasticsearchConnector.class).in(Scopes.SINGLETON); binder.bind(ElasticsearchMetadata.class).in(Scopes.SINGLETON); binder.bind(ElasticsearchSplitManager.class).in(Scopes.SINGLETON); binder.bind(ElasticsearchRecordSetProvider.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(ElasticsearchConnectorConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(ElasticsearchTableDescription.class); binder.install(new DecoderModule()); }
binder.bind(ConnectorNodePartitioningProvider.class).to(HiveNodePartitioningProvider.class).in(Scopes.SINGLETON); jsonCodecBinder(binder).bindJsonCodec(PartitionUpdate.class);
@Override public void configure(Binder binder) { binder.bind(JsonMapper.class); configBinder(binder).bindConfig(FeaturesConfig.class); binder.bind(TypeRegistry.class).in(Scopes.SINGLETON); binder.bind(TypeManager.class).to(TypeRegistry.class).in(Scopes.SINGLETON); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); newSetBinder(binder, Type.class); jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class); }
jsonCodecBinder(binder).bindJsonCodec(ViewDefinition.class); binder.bind(LookupJoinOperators.class).in(Scopes.SINGLETON); jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class); jsonCodecBinder(binder).bindJsonCodec(StageInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(OperatorStats.class); jsonCodecBinder(binder).bindJsonCodec(ExecutionFailureInfo.class); jaxrsBinder(binder).bind(PagesResponseWriter.class); jsonCodecBinder(binder).bindJsonCodec(MemoryInfo.class); jsonCodecBinder(binder).bindJsonCodec(MemoryPoolAssignmentsRequest.class); jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class); jsonCodecBinder(binder).bindJsonCodec(ConnectorSplit.class); jsonBinder(binder).addSerializerBinding(Slice.class).to(SliceSerializer.class); jsonBinder(binder).addDeserializerBinding(Slice.class).to(SliceDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(ServerInfo.class); jsonCodecBinder(binder).bindJsonCodec(NodeStatus.class);
jsonCodecBinder(binder).bindJsonCodec(QueryInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(QueryResults.class); jaxrsBinder(binder).bind(StatementResource.class); binder.bind(StatementHttpExecutionMBean.class).in(Scopes.SINGLETON);
@Override public void configure(Binder binder) { binder.bind(KafkaConnector.class).in(Scopes.SINGLETON); binder.bind(KafkaMetadata.class).in(Scopes.SINGLETON); binder.bind(KafkaSplitManager.class).in(Scopes.SINGLETON); binder.bind(KafkaRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(KafkaSimpleConsumerManager.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(KafkaConnectorConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(KafkaTopicDescription.class); binder.install(new DecoderModule()); }
@Override public void configure(Binder binder) { binder.bind(RedisConnector.class).in(Scopes.SINGLETON); binder.bind(RedisMetadata.class).in(Scopes.SINGLETON); binder.bind(RedisSplitManager.class).in(Scopes.SINGLETON); binder.bind(RedisRecordSetProvider.class).in(Scopes.SINGLETON); binder.bind(RedisJedisManager.class).in(Scopes.SINGLETON); configBinder(binder).bindConfig(RedisConnectorConfig.class); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); jsonCodecBinder(binder).bindJsonCodec(RedisTableDescription.class); binder.install(new RedisDecoderModule()); }
@Override public void configure(Binder binder) { jsonCodecBinder(binder).bindJsonCodec(Integer.class); jsonCodecBinder(binder).bindJsonCodec(Integer.class); binder.bind(Dummy.class).in(Scopes.SINGLETON); } });
@Test public void ignoresRepeatedBinding() { Injector injector = Guice.createInjector((Module) binder -> { jsonCodecBinder(binder).bindJsonCodec(Integer.class); jsonCodecBinder(binder).bindJsonCodec(Integer.class); binder.bind(Dummy.class).in(Scopes.SINGLETON); }); assertNotNull(injector.getInstance(Dummy.class).getCodec()); }
@Test public void ignoresRepeatedBinding() { Injector injector = Guice.createInjector((Module) binder -> { jsonCodecBinder(binder).bindJsonCodec(Integer.class); jsonCodecBinder(binder).bindJsonCodec(Integer.class); binder.bind(Dummy.class).in(Scopes.SINGLETON); }); assertNotNull(injector.getInstance(Dummy.class).getCodec()); }
@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 public void configure(Binder binder) { binder.bind(JsonMapper.class); configBinder(binder).bindConfig(FeaturesConfig.class); binder.bind(TypeRegistry.class).in(Scopes.SINGLETON); binder.bind(TypeManager.class).to(TypeRegistry.class).in(Scopes.SINGLETON); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); newSetBinder(binder, Type.class); jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class); }
@Override public void configure(Binder binder) { binder.bind(JsonMapper.class); configBinder(binder).bindConfig(FeaturesConfig.class); binder.bind(TypeRegistry.class).in(Scopes.SINGLETON); binder.bind(TypeManager.class).to(TypeRegistry.class).in(Scopes.SINGLETON); jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class); newSetBinder(binder, Type.class); jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class); jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class); jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.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"); } }
@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); } }
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); } }