From: Kai Moritz Date: Mon, 19 Feb 2024 12:07:35 +0000 (+0100) Subject: refactor: Extracted annonymous class into `NoStorageStorageStrategy` X-Git-Tag: rebase--2024-02-20--09-03~10 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=406a1f6a545eb9f79b54a2780fe793789767af40;p=demos%2Fkafka%2Fchat refactor: Extracted annonymous class into `NoStorageStorageStrategy` -- ALIGN --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java index 1b20aa37..2e499ef3 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java @@ -1,7 +1,5 @@ package de.juplo.kafka.chat.backend.storage.nostorage; -import de.juplo.kafka.chat.backend.domain.ChatRoomInfo; -import de.juplo.kafka.chat.backend.domain.Message; import de.juplo.kafka.chat.backend.implementation.StorageStrategy; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -9,9 +7,6 @@ import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoCo import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import reactor.core.publisher.Flux; - -import java.util.UUID; @ConditionalOnProperty( @@ -29,25 +24,6 @@ public class NoStorageStorageConfiguration @Bean public StorageStrategy storageStrategy() { - return new StorageStrategy() - { - @Override - public void writeChatRoomInfo(Flux chatRoomInfoFlux) {} - - @Override - public Flux readChatRoomInfo() - { - return Flux.empty(); - } - - @Override - public void writeChatRoomData(UUID chatRoomId, Flux messageFlux) {} - - @Override - public Flux readChatRoomData(UUID chatRoomId) - { - return Flux.empty(); - } - }; + return new NoStorageStorageStrategy(); } } diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageStrategy.java index 1b20aa37..79f36d79 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageStrategy.java @@ -3,51 +3,28 @@ package de.juplo.kafka.chat.backend.storage.nostorage; import de.juplo.kafka.chat.backend.domain.ChatRoomInfo; import de.juplo.kafka.chat.backend.domain.Message; import de.juplo.kafka.chat.backend.implementation.StorageStrategy; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import reactor.core.publisher.Flux; import java.util.UUID; -@ConditionalOnProperty( - prefix = "chat.backend.inmemory", - name = "storage-strategy", - havingValue = "none", - matchIfMissing = true) -@Configuration -@EnableAutoConfiguration( - exclude = { - MongoRepositoriesAutoConfiguration.class, - MongoAutoConfiguration.class }) -public class NoStorageStorageConfiguration +public class NoStorageStorageStrategy implements StorageStrategy { - @Bean - public StorageStrategy storageStrategy() - { - return new StorageStrategy() - { - @Override - public void writeChatRoomInfo(Flux chatRoomInfoFlux) {} + @Override + public void writeChatRoomInfo(Flux chatRoomInfoFlux) {} - @Override - public Flux readChatRoomInfo() - { - return Flux.empty(); - } + @Override + public Flux readChatRoomInfo() + { + return Flux.empty(); + } - @Override - public void writeChatRoomData(UUID chatRoomId, Flux messageFlux) {} + @Override + public void writeChatRoomData(UUID chatRoomId, Flux messageFlux) {} - @Override - public Flux readChatRoomData(UUID chatRoomId) - { - return Flux.empty(); - } - }; + @Override + public Flux readChatRoomData(UUID chatRoomId) + { + return Flux.empty(); } }