TMP
authorKai Moritz <kai@juplo.de>
Fri, 23 Feb 2024 11:42:34 +0000 (12:42 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 23 Feb 2024 15:13:05 +0000 (16:13 +0100)
src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java
src/test/java/de/juplo/kafka/chat/backend/MongoDbStorageNotActiveConfiguration.java [deleted file]

diff --git a/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageNotActiveConfiguration.java
new file mode 100644 (file)
index 0000000..18ec241
--- /dev/null
@@ -0,0 +1,22 @@
+package de.juplo.kafka.chat.backend.storage.mongodb;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+
+
+@ConditionalOnExpression("#{${chat.backend.inmemory.storage-strategy} != 'mongodb'}")
+@Configuration
+@Slf4j
+public class MongoDbStorageNotActiveConfiguration
+{
+  @Bean
+  @Lazy(false)
+  public String foo()
+  {
+    log.info("FOO!");
+    return "FOO";
+  }
+}
index d497d95..47e5978 100644 (file)
@@ -5,7 +5,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
 
 
 @ConditionalOnProperty(
@@ -22,12 +21,4 @@ public class NoStorageStorageConfiguration
   {
     return new NoStorageStorageStrategy();
   }
-
-  @Bean
-  @Lazy(false)
-  public String foo()
-  {
-    log.info("FOO (woanders)!");
-    return "FOO";
-  }
 }
diff --git a/src/test/java/de/juplo/kafka/chat/backend/MongoDbStorageNotActiveConfiguration.java b/src/test/java/de/juplo/kafka/chat/backend/MongoDbStorageNotActiveConfiguration.java
deleted file mode 100644 (file)
index 47d4c7d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package de.juplo.kafka.chat.backend;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
-
-
-@Configuration
-@Slf4j
-public class MongoDbStorageNotActiveConfiguration
-{
-  @Bean
-  @Lazy(false)
-  public String foo()
-  {
-    log.info("FOO!");
-    return "FOO";
-  }
-}