Skip to content

Commit

Permalink
Infinispan Dev UI without infinispan configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti authored and gsmet committed Aug 2, 2021
1 parent 72cc2d6 commit 49c7e70
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<a target="_blank" href="http://{info:remoteCacheManager.configuration.servers.get(0).host}:{info:remoteCacheManager.configuration.servers.get(0).port}" class="badge badge-light">
{#if info:serverUrl != ""}
<a target="_blank" href="http://{info:serverUrl}" class="badge badge-light">
<i class="fa fa-external-link-alt fa-fw"></i> Web Console</a>
<br>
<a target="_blank" href="http://infinispan.org" class="badge badge-light">
{#else}
<span class="badge badge-light">
<i class="fa fa-exclamation-triangle fa-fw"></i> Configuration is missing</span>
<br>
{/if}
<a target="_blank" href="https://infinispan.org/documentation/" class="badge badge-light">
<i class="fas fa-info fa-fw"></i> Documentation</a>
<br>
<a target="_blank" href="https://github.com/infinispan/infinispan-simple-tutorials" class="badge badge-light">
<i class="fa fa-hand-point-right fa-fw"></i> Simple Tutorials</a>
<i class="fa fa-hand-point-right fa-fw"></i> Code Tutorials</a>
<br>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<String> {

@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();
}
}

0 comments on commit 49c7e70

Please sign in to comment.