From 53a7faa1310941eaff19eaafd8da52ec56de1e22 Mon Sep 17 00:00:00 2001 From: Wiktor Garbarek Date: Tue, 26 Jun 2018 16:43:52 +0200 Subject: Refactor of KafkaEventPublisher Moved constructors; added annotation Change-Id: I0223df163a3dd759ff83e490d9d646e232a21a34 Issue-ID: AAI-1249 Signed-off-by: Wiktor Garbarek --- .../onap/aai/event/client/KafkaEventPublisher.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/event-client-kafka/src/main/java/org/onap/aai/event/client/KafkaEventPublisher.java b/event-client-kafka/src/main/java/org/onap/aai/event/client/KafkaEventPublisher.java index 2b98e27..098f1f8 100644 --- a/event-client-kafka/src/main/java/org/onap/aai/event/client/KafkaEventPublisher.java +++ b/event-client-kafka/src/main/java/org/onap/aai/event/client/KafkaEventPublisher.java @@ -42,6 +42,7 @@ public class KafkaEventPublisher implements EventPublisher { private static Logger log = LoggerFactory.getInstance().getLogger(KafkaEventPublisher.class); + @FunctionalInterface public interface KafkaProducerFactory { public KafkaProducer createProducer(Properties props); } @@ -53,15 +54,6 @@ public class KafkaEventPublisher implements EventPublisher { private final KafkaProducer producer; private final String topic; - /** - * Replace the producer factory (intended to be used for testing purposes only). - * - * @param producerFactory - */ - static void setProducerFactory(KafkaProducerFactory producerFactory) { - KafkaEventPublisher.producerFactory = producerFactory; - } - /** * * @param hosts - A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. The @@ -108,6 +100,15 @@ public class KafkaEventPublisher implements EventPublisher { this.topic = topic; } + /** + * Replace the producer factory (intended to be used for testing purposes only). + * + * @param producerFactory + */ + static void setProducerFactory(KafkaProducerFactory producerFactory) { + KafkaEventPublisher.producerFactory = producerFactory; + } + /** * Closes the publisher. */ -- cgit 1.2.3-korg