From 78482b36cbe290b95b63d76c898de6ac1962e131 Mon Sep 17 00:00:00 2001 From: Artem Sidorkin Date: Tue, 19 Jan 2021 11:28:17 +0300 Subject: [PATCH] Fixed bean scopes. See: https://github.com/eventuate-tram/eventuate-tram-core-quarkus/issues/3 --- ...aConsumerConfigurationPropertiesConfiguration.java | 7 +++---- .../common/EventuateKafkaPropertiesConfiguration.java | 7 +++---- .../consumer/KafkaConsumerFactoryConfiguration.java | 8 ++++---- .../consumer/MessageConsumerKafkaConfiguration.java | 7 +++---- .../EventuateKafkaProducerConsumerConfiguration.java | 11 +++++------ ...aProducerConfigurationPropertiesConfiguration.java | 7 +++---- 6 files changed, 21 insertions(+), 26 deletions(-) diff --git a/eventuate-messaging-kafka-quarkus-basic-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/basic/consumer/EventuateKafkaConsumerConfigurationPropertiesConfiguration.java b/eventuate-messaging-kafka-quarkus-basic-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/basic/consumer/EventuateKafkaConsumerConfigurationPropertiesConfiguration.java index 21643f4..1589b23 100755 --- a/eventuate-messaging-kafka-quarkus-basic-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/basic/consumer/EventuateKafkaConsumerConfigurationPropertiesConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-basic-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/basic/consumer/EventuateKafkaConsumerConfigurationPropertiesConfiguration.java @@ -2,12 +2,11 @@ import io.eventuate.messaging.kafka.basic.consumer.EventuateKafkaConsumerConfigurationProperties; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; -@ApplicationScoped +@Singleton public class EventuateKafkaConsumerConfigurationPropertiesConfiguration { - @Produces + @Singleton public EventuateKafkaConsumerConfigurationProperties eventuateKafkaConsumerConfigurationProperties(EventuateKafkaConsumerQuarkusConfigurationProperties eventuateKafkaConsumerQuarkusConfigurationProperties) { EventuateKafkaConsumerConfigurationProperties eventuateKafkaConsumerConfigurationProperties = new EventuateKafkaConsumerConfigurationProperties(eventuateKafkaConsumerQuarkusConfigurationProperties.getPropertiesAsMap()); eventuateKafkaConsumerConfigurationProperties.setBackPressure(eventuateKafkaConsumerQuarkusConfigurationProperties.getBackPressure().toBackPressureConfig()); diff --git a/eventuate-messaging-kafka-quarkus-common/src/main/java/io/eventuate/messaging/kafka/quarkus/common/EventuateKafkaPropertiesConfiguration.java b/eventuate-messaging-kafka-quarkus-common/src/main/java/io/eventuate/messaging/kafka/quarkus/common/EventuateKafkaPropertiesConfiguration.java index 239eb4e..14c3565 100755 --- a/eventuate-messaging-kafka-quarkus-common/src/main/java/io/eventuate/messaging/kafka/quarkus/common/EventuateKafkaPropertiesConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-common/src/main/java/io/eventuate/messaging/kafka/quarkus/common/EventuateKafkaPropertiesConfiguration.java @@ -3,13 +3,12 @@ import io.eventuate.messaging.kafka.common.EventuateKafkaConfigurationProperties; import org.eclipse.microprofile.config.inject.ConfigProperty; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; -@ApplicationScoped +@Singleton public class EventuateKafkaPropertiesConfiguration { - @Produces + @Singleton public EventuateKafkaConfigurationProperties eventuateKafkaConfigurationProperties(@ConfigProperty(name = "eventuatelocal.kafka.bootstrap.servers") String bootstrapServers, @ConfigProperty(name = "eventuatelocal.kafka.connection.validation.timeout", defaultValue = "1000") diff --git a/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/KafkaConsumerFactoryConfiguration.java b/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/KafkaConsumerFactoryConfiguration.java index 1ba42f5..b959e40 100755 --- a/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/KafkaConsumerFactoryConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/KafkaConsumerFactoryConfiguration.java @@ -1,14 +1,14 @@ package io.eventuate.messaging.kafka.quarkus.consumer; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; + import io.eventuate.messaging.kafka.basic.consumer.DefaultKafkaConsumerFactory; import io.eventuate.messaging.kafka.basic.consumer.KafkaConsumerFactory; import io.quarkus.arc.DefaultBean; -@ApplicationScoped +@Singleton public class KafkaConsumerFactoryConfiguration { - @Produces + @Singleton @DefaultBean public KafkaConsumerFactory kafkaConsumerFactory() { return new DefaultKafkaConsumerFactory(); diff --git a/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/MessageConsumerKafkaConfiguration.java b/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/MessageConsumerKafkaConfiguration.java index f10e4e3..3bf8817 100755 --- a/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/MessageConsumerKafkaConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-consumer/src/main/java/io/eventuate/messaging/kafka/quarkus/consumer/MessageConsumerKafkaConfiguration.java @@ -5,12 +5,11 @@ import io.eventuate.messaging.kafka.common.EventuateKafkaConfigurationProperties; import io.eventuate.messaging.kafka.consumer.MessageConsumerKafkaImpl; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; -@ApplicationScoped +@Singleton public class MessageConsumerKafkaConfiguration { - @Produces + @Singleton public MessageConsumerKafkaImpl messageConsumerKafka(EventuateKafkaConfigurationProperties props, EventuateKafkaConsumerConfigurationProperties eventuateKafkaConsumerConfigurationProperties, KafkaConsumerFactory kafkaConsumerFactory) { diff --git a/eventuate-messaging-kafka-quarkus-integration-test/src/test/java/io/eventuate/messaging/kafka/quarkus/integration/tests/EventuateKafkaProducerConsumerConfiguration.java b/eventuate-messaging-kafka-quarkus-integration-test/src/test/java/io/eventuate/messaging/kafka/quarkus/integration/tests/EventuateKafkaProducerConsumerConfiguration.java index df73b44..c6f0192 100755 --- a/eventuate-messaging-kafka-quarkus-integration-test/src/test/java/io/eventuate/messaging/kafka/quarkus/integration/tests/EventuateKafkaProducerConsumerConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-integration-test/src/test/java/io/eventuate/messaging/kafka/quarkus/integration/tests/EventuateKafkaProducerConsumerConfiguration.java @@ -8,24 +8,23 @@ import io.eventuate.messaging.kafka.producer.EventuateKafkaProducer; import io.eventuate.messaging.kafka.producer.EventuateKafkaProducerConfigurationProperties; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; -@ApplicationScoped +@Singleton public class EventuateKafkaProducerConsumerConfiguration { - @Produces + @Singleton public EventuateKafkaProducer producer(EventuateKafkaConfigurationProperties kafkaProperties, EventuateKafkaProducerConfigurationProperties producerProperties) { return new EventuateKafkaProducer(kafkaProperties.getBootstrapServers(), producerProperties); } - @Produces + @Singleton public MessageConsumerKafkaImpl messageConsumerKafka(EventuateKafkaConfigurationProperties props, EventuateKafkaConsumerConfigurationProperties eventuateKafkaConsumerConfigurationProperties, KafkaConsumerFactory kafkaConsumerFactory) { return new MessageConsumerKafkaImpl(props.getBootstrapServers(), eventuateKafkaConsumerConfigurationProperties, kafkaConsumerFactory); } - @Produces + @Singleton public KafkaConsumerFactory kafkaConsumerFactory() { return new DefaultKafkaConsumerFactory(); } diff --git a/eventuate-messaging-kafka-quarkus-producer/src/main/java/io/eventuate/messaging/kafka/quarkus/producer/EventuateKafkaProducerConfigurationPropertiesConfiguration.java b/eventuate-messaging-kafka-quarkus-producer/src/main/java/io/eventuate/messaging/kafka/quarkus/producer/EventuateKafkaProducerConfigurationPropertiesConfiguration.java index 121b211..f632155 100755 --- a/eventuate-messaging-kafka-quarkus-producer/src/main/java/io/eventuate/messaging/kafka/quarkus/producer/EventuateKafkaProducerConfigurationPropertiesConfiguration.java +++ b/eventuate-messaging-kafka-quarkus-producer/src/main/java/io/eventuate/messaging/kafka/quarkus/producer/EventuateKafkaProducerConfigurationPropertiesConfiguration.java @@ -2,12 +2,11 @@ import io.eventuate.messaging.kafka.producer.EventuateKafkaProducerConfigurationProperties; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import javax.inject.Singleton; -@ApplicationScoped +@Singleton public class EventuateKafkaProducerConfigurationPropertiesConfiguration { - @Produces + @Singleton public EventuateKafkaProducerConfigurationProperties eventuateKafkaProducerConfigurationProperties(EventuateKafkaProducerQuarkusConfigurationProperties eventuateKafkaProducerQuarkusConfigurationProperties) { return new EventuateKafkaProducerConfigurationProperties(eventuateKafkaProducerQuarkusConfigurationProperties.getPropertiesAsMap()); }