20e6ed434627a0e472729de5a51104e2ba997d5e
[demos/kafka/chat] /
1 package de.juplo.kafka.chat.backend.persistence.storage.mongodb;
2
3 import de.juplo.kafka.chat.backend.persistence.inmemory.ShardingStrategy;
4 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
5 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration;
8
9
10 @ConditionalOnProperty(
11     prefix = "chat.backend.inmemory",
12     name = "storage-strategy",
13     havingValue = "mongodb")
14 @Configuration
15 public class MongoDbStorageConfiguration
16 {
17   @Bean
18   public StorageStrategy storageStrategy(
19       ChatRoomRepository chatRoomRepository,
20       MessageRepository messageRepository,
21       ShardingStrategy shardingStrategy)
22   {
23     return new MongoDbStorageStrategy(
24         chatRoomRepository,
25         messageRepository,
26         shardingStrategy);
27   }
28 }