From 49c7e70241e3e5335c6f4caf1571de2596ec7774 Mon Sep 17 00:00:00 2001 From: Katia Aresti Date: Thu, 29 Jul 2021 17:05:28 +0200 Subject: [PATCH] Infinispan Dev UI without infinispan configuration --- .../InfinispanDevConsoleProcessor.java | 6 ++--- .../resources/dev-templates/embedded.html | 12 ++++++--- .../runtime/InfinispanClientSupplier.java | 20 -------------- .../runtime/InfinispanServerUrlSupplier.java | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+), 26 deletions(-) delete mode 100644 extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientSupplier.java create mode 100644 extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanServerUrlSupplier.java diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devconsole/InfinispanDevConsoleProcessor.java b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devconsole/InfinispanDevConsoleProcessor.java index e367fc06a259e..6ef5c3930cd78 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devconsole/InfinispanDevConsoleProcessor.java +++ b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devconsole/InfinispanDevConsoleProcessor.java @@ -3,12 +3,12 @@ import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem; -import io.quarkus.infinispan.client.runtime.InfinispanClientSupplier; +import io.quarkus.infinispan.client.runtime.InfinispanServerUrlSupplier; public class InfinispanDevConsoleProcessor { @BuildStep(onlyIf = IsDevelopment.class) - public DevConsoleRuntimeTemplateInfoBuildItem remoteCacheManager() { - return new DevConsoleRuntimeTemplateInfoBuildItem("remoteCacheManager", new InfinispanClientSupplier()); + public DevConsoleRuntimeTemplateInfoBuildItem infinispanServer() { + return new DevConsoleRuntimeTemplateInfoBuildItem("serverUrl", new InfinispanServerUrlSupplier()); } } diff --git a/extensions/infinispan-client/deployment/src/main/resources/dev-templates/embedded.html b/extensions/infinispan-client/deployment/src/main/resources/dev-templates/embedded.html index 5443a9930a809..ff40695d67944 100644 --- a/extensions/infinispan-client/deployment/src/main/resources/dev-templates/embedded.html +++ b/extensions/infinispan-client/deployment/src/main/resources/dev-templates/embedded.html @@ -1,9 +1,15 @@ - +{#if info:serverUrl != ""} + Web Console
- +{#else} + + Configuration is missing +
+{/if} +
Documentation
- Simple Tutorials + Code Tutorials
\ No newline at end of file diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientSupplier.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientSupplier.java deleted file mode 100644 index b6971193dca58..0000000000000 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientSupplier.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.quarkus.infinispan.client.runtime; - -import java.util.function.Supplier; - -import org.infinispan.client.hotrod.RemoteCacheManager; - -import io.quarkus.arc.Arc; - -public class InfinispanClientSupplier implements Supplier { - - @Override - public RemoteCacheManager get() { - RemoteCacheManager cacheManager = cacheManager(); - return cacheManager; - } - - public static RemoteCacheManager cacheManager() { - return Arc.container().instance(RemoteCacheManager.class).get(); - } -} diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanServerUrlSupplier.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanServerUrlSupplier.java new file mode 100644 index 0000000000000..efceeea562f4b --- /dev/null +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanServerUrlSupplier.java @@ -0,0 +1,26 @@ +package io.quarkus.infinispan.client.runtime; + +import java.util.function.Supplier; + +import org.infinispan.client.hotrod.RemoteCacheManager; +import org.infinispan.client.hotrod.configuration.ServerConfiguration; + +import io.quarkus.arc.Arc; + +public class InfinispanServerUrlSupplier implements Supplier { + + @Override + public String get() { + RemoteCacheManager cacheManager = cacheManager(); + if (cacheManager == null || cacheManager.getConfiguration().servers().isEmpty()) { + return ""; + } + ServerConfiguration firstServer = cacheManager.getConfiguration().servers().get(0); + + return firstServer.host() + ":" + firstServer.port(); + } + + public static RemoteCacheManager cacheManager() { + return Arc.container().instance(RemoteCacheManager.class).get(); + } +}