refactor: Only `LocalJsonFileStorageStrategy` restores `Chatroom`s
authorKai Moritz <kai@juplo.de>
Sun, 8 Jan 2023 08:53:03 +0000 (09:53 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 18:35:59 +0000 (19:35 +0100)
src/main/java/de/juplo/kafka/chat/backend/ChatBackendConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/domain/ChatroomFactory.java
src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatroomFactory.java
src/main/java/de/juplo/kafka/chat/backend/persistence/LocalJsonFilesStorageStrategy.java

index b590854..b9d1d29 100644 (file)
@@ -30,7 +30,7 @@ public class ChatBackendConfiguration
   public StorageStrategy storageStrategy(
       ChatBackendProperties properties,
       ObjectMapper mapper,
-      ChatroomFactory chatroomFactory)
+      InMemoryChatroomFactory chatroomFactory)
   {
     return new LocalJsonFilesStorageStrategy(
         Paths.get(properties.getDatadir()),
@@ -39,7 +39,7 @@ public class ChatBackendConfiguration
   }
 
   @Bean
-  ChatroomFactory chatroomFactory(ChatBackendProperties properties)
+  InMemoryChatroomFactory chatroomFactory(ChatBackendProperties properties)
   {
     return new InMemoryChatroomFactory(properties.getChatroomBufferSize());
   }
index f5e8c19..6e77095 100644 (file)
@@ -6,5 +6,4 @@ import java.util.UUID;
 public interface ChatroomFactory<Strategy extends PersistenceStrategy>
 {
   Chatroom createChatroom(UUID id, String name);
-  Chatroom restoreChatroom(UUID id, String name, Strategy strategy);
 }
index a405be9..6e4985e 100644 (file)
@@ -22,7 +22,6 @@ public class InMemoryChatroomFactory implements ChatroomFactory<InMemoryPersiste
     return new Chatroom(id, name, persistenceStrategy, bufferSize);
   }
 
-  @Override
   public Chatroom restoreChatroom(
       UUID id,
       String name,
index c195893..28008f4 100644 (file)
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import de.juplo.kafka.chat.backend.api.ChatroomTo;
 import de.juplo.kafka.chat.backend.api.MessageTo;
 import de.juplo.kafka.chat.backend.domain.Chatroom;
-import de.juplo.kafka.chat.backend.domain.ChatroomFactory;
 import de.juplo.kafka.chat.backend.domain.Message;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -29,7 +28,7 @@ public class LocalJsonFilesStorageStrategy implements StorageStrategy
 
   private final Path storagePath;
   private final ObjectMapper mapper;
-  private final ChatroomFactory chatroomFactory;
+  private final InMemoryChatroomFactory chatroomFactory;
 
 
   @Override