diff --git a/extensions/caffeine/deployment/pom.xml b/extensions/caffeine/deployment/pom.xml index 64c391724995f..1bbde72ebb0cc 100644 --- a/extensions/caffeine/deployment/pom.xml +++ b/extensions/caffeine/deployment/pom.xml @@ -21,6 +21,10 @@ io.quarkus quarkus-caffeine + + io.quarkus + quarkus-vertx-http-dev-ui-spi + diff --git a/extensions/caffeine/deployment/src/main/java/io/quarkus/caffeine/deployment/devui/CaffeineDevUIProcessor.java b/extensions/caffeine/deployment/src/main/java/io/quarkus/caffeine/deployment/devui/CaffeineDevUIProcessor.java new file mode 100644 index 0000000000000..69218ad0d29b4 --- /dev/null +++ b/extensions/caffeine/deployment/src/main/java/io/quarkus/caffeine/deployment/devui/CaffeineDevUIProcessor.java @@ -0,0 +1,48 @@ +package io.quarkiverse.caffeine.deployment.devui; + +import java.io.InputStream; +import java.net.URL; +import java.util.jar.Manifest; + +import com.github.benmanes.caffeine.cache.Caffeine; + +import io.quarkus.deployment.IsDevelopment; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.devui.spi.page.CardPageBuildItem; +import io.quarkus.devui.spi.page.Page; +import io.quarkus.devui.spi.page.PageBuilder; + +/** + * Dev UI card for displaying important details such as the Caffeine library version. + */ +public class CaffeineDevUIProcessor { + + @BuildStep(onlyIf = IsDevelopment.class) + void createCard(BuildProducer cardPageBuildItemBuildProducer) { + final CardPageBuildItem card = new CardPageBuildItem("Caffeine"); + + final PageBuilder versionPage = Page.externalPageBuilder("Version") + .icon("font-awesome-solid:mug-hot") + .url("https://github.com/ben-manes/caffeine") + .doNotEmbed() + .staticLabel(getManifest(Caffeine.class).getMainAttributes().getValue("Bundle-Version")); + card.addPage(versionPage); + + card.setCustomCard("qwc-caffeine-card.js"); + + cardPageBuildItemBuildProducer.produce(card); + } + + public static Manifest getManifest(Class clz) { + String resource = "/" + clz.getName().replace(".", "/") + ".class"; + String fullPath = clz.getResource(resource).toString(); + String archivePath = fullPath.substring(0, fullPath.length() - resource.length()); + + try (InputStream input = new URL(archivePath + "/META-INF/MANIFEST.MF").openStream()) { + return new Manifest(input); + } catch (Exception e) { + throw new RuntimeException("Loading MANIFEST for class " + clz + " failed!", e); + } + } +} diff --git a/extensions/caffeine/deployment/src/main/resources/dev-ui/caffeine/qwc-caffeine-card.js b/extensions/caffeine/deployment/src/main/resources/dev-ui/caffeine/qwc-caffeine-card.js new file mode 100644 index 0000000000000..51cafedb260ce --- /dev/null +++ b/extensions/caffeine/deployment/src/main/resources/dev-ui/caffeine/qwc-caffeine-card.js @@ -0,0 +1,84 @@ +import { LitElement, html, css} from 'lit'; +import { pages } from 'caffeine-data'; +import 'qwc/qwc-extension-link.js'; + +const NAME = "Caffeine"; +export class QwcCaffeineCard extends LitElement { + + static styles = css` + .identity { + display: flex; + justify-content: flex-start; + } + + .description { + padding-bottom: 10px; + } + + .logo { + padding-bottom: 10px; + margin-right: 5px; + } + + .card-content { + color: var(--lumo-contrast-90pct); + display: flex; + flex-direction: column; + justify-content: flex-start; + padding: 10px 10px; + height: 100%; + } + + .card-content slot { + display: flex; + flex-flow: column wrap; + padding-top: 5px; + } + `; + + static properties = { + description: {type: String} + }; + + constructor() { + super(); + } + + connectedCallback() { + super.connectedCallback(); + } + + render() { + return html`
+
+ +
${this.description}
+
+ ${this._renderCardLinks()} +
+ `; + } + + _renderCardLinks(){ + return html`${pages.map(page => html` + + + `)}`; + } + +} +customElements.define('qwc-caffeine-card', QwcCaffeineCard); \ No newline at end of file diff --git a/extensions/caffeine/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/caffeine/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 76cb4ce0008bc..f70030a786617 100644 --- a/extensions/caffeine/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/caffeine/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -1,6 +1,7 @@ --- artifact: ${project.groupId}:${project.artifactId}:${project.version} name: "Caffeine" +description: "Caffeine is a high performance, near optimal caching library." metadata: keywords: - "cache"