From: Kai Moritz Date: Wed, 13 Sep 2023 19:20:39 +0000 (+0200) Subject: refactor: `KafkaServicesApplicationRunner` without autowireing X-Git-Tag: rebase--2024-02-03--15-10~24 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ed80071cc73b408e971d7238460bd9ce3d8114e7;p=demos%2Fkafka%2Fchat refactor: `KafkaServicesApplicationRunner` without autowireing --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesApplicationRunner.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesApplicationRunner.java index 70e41e1d..8b701807 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesApplicationRunner.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaServicesApplicationRunner.java @@ -3,13 +3,13 @@ package de.juplo.kafka.chat.backend.implementation.kafka; import de.juplo.kafka.chat.backend.ChatBackendProperties; import de.juplo.kafka.chat.backend.implementation.kafka.messages.AbstractMessageTo; import jakarta.annotation.PreDestroy; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.consumer.Consumer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; @@ -22,21 +22,14 @@ import java.util.concurrent.CompletableFuture; name = "services", havingValue = "kafka") @Component +@RequiredArgsConstructor @Slf4j public class KafkaServicesApplicationRunner implements ApplicationRunner { - @Autowired - ChatBackendProperties properties; - - @Autowired - ThreadPoolTaskExecutor taskExecutor; - @Autowired - ConfigurableApplicationContext context; - - @Autowired - ChatRoomChannel chatRoomChannel; - @Autowired - Consumer chatRoomChannelConsumer; + private final ChatBackendProperties properties; + private final ThreadPoolTaskExecutor taskExecutor; + private final ChatRoomChannel chatRoomChannel; + private final Consumer chatRoomChannelConsumer; CompletableFuture chatRoomChannelConsumerJob;