import de.juplo.kafka.chat.backend.domain.ChatHome;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.juplo.kafka.chat.backend.domain.ChatroomFactory;
-import de.juplo.kafka.chat.backend.domain.Message;
import de.juplo.kafka.chat.backend.persistence.InMemoryChatroomFactory;
-import de.juplo.kafka.chat.backend.persistence.InMemoryPersistenceStrategy;
import de.juplo.kafka.chat.backend.persistence.LocalJsonFilesStorageStrategy;
import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import java.nio.file.Paths;
import java.time.Clock;
-import java.util.LinkedHashMap;
@Configuration
}
@Bean
- ChatroomFactory chatroomFactory(InMemoryPersistenceStrategy persistenceStrategy)
+ ChatroomFactory chatroomFactory()
{
- return new InMemoryChatroomFactory(persistenceStrategy);
- }
-
- @Bean
- InMemoryPersistenceStrategy persistenceStrategy()
- {
- return new InMemoryPersistenceStrategy(new LinkedHashMap<>());
+ return new InMemoryChatroomFactory();
}
@Bean
@RequiredArgsConstructor
public class InMemoryChatroomFactory implements ChatroomFactory<InMemoryPersistenceStrategy>
{
- private final PersistenceStrategy persistenceStrategy;
-
-
@Override
public Chatroom createChatroom(UUID id, String name)
{
+ InMemoryPersistenceStrategy persistenceStrategy =
+ new InMemoryPersistenceStrategy(new LinkedHashMap<>());
return new Chatroom(id, name, persistenceStrategy);
}