This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 44220440e8 Add Diagram extension and DevUI page
44220440e8 is described below
commit 44220440e8be10ed2152c93900a61e37a9a0a5ee
Author: James Netherton <[email protected]>
AuthorDate: Fri Jul 10 15:53:32 2026 +0100
Add Diagram extension and DevUI page
Fixes #8624
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
catalog/pom.xml | 13 ++
docs/modules/ROOT/examples/others/diagram.yml | 13 ++
docs/modules/ROOT/nav.adoc | 1 +
.../ROOT/pages/reference/extensions/diagram.adoc | 41 +++++++
.../devui/CamelCoreDevConsoleProcessor.java | 5 +
.../resources/dev-ui/qwc-camel-core-diagram.js | 134 +++++++++++++++++++++
extensions-core/core/runtime/pom.xml | 1 +
extensions-jvm/diagram/deployment/pom.xml | 61 ++++++++++
.../diagram/deployment/DiagramProcessor.java | 62 ++++++++++
extensions-jvm/diagram/pom.xml | 37 ++++++
extensions-jvm/diagram/runtime/pom.xml | 70 +++++++++++
.../component/diagram/CamelDiagramRecorder.java | 113 +++++++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 37 ++++++
extensions-jvm/pom.xml | 1 +
integration-tests-jvm/diagram/pom.xml | 112 +++++++++++++++++
.../component/diagram/it/DiagramRoutes.java | 28 +++++
.../quarkus/component/diagram/it/DiagramTest.java | 86 +++++++++++++
integration-tests-jvm/pom.xml | 1 +
poms/bom/pom.xml | 15 +++
poms/bom/src/main/generated/flattened-full-pom.xml | 15 +++
.../src/main/generated/flattened-reduced-pom.xml | 15 +++
.../generated/flattened-reduced-verbose-pom.xml | 15 +++
22 files changed, 876 insertions(+)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index b177604a30..ae8718b537 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -1189,6 +1189,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-digitalocean</artifactId>
diff --git a/docs/modules/ROOT/examples/others/diagram.yml
b/docs/modules/ROOT/examples/others/diagram.yml
new file mode 100644
index 0000000000..1333eb30ec
--- /dev/null
+++ b/docs/modules/ROOT/examples/others/diagram.yml
@@ -0,0 +1,13 @@
+# Do not edit directly!
+# This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+cqArtifactId: camel-quarkus-diagram
+cqArtifactIdBase: diagram
+cqNativeSupported: false
+cqStatus: Preview
+cqDeprecated: false
+cqJvmSince: 3.38.0
+cqNativeSince: n/a
+cqCamelPartName: diagram
+cqCamelPartTitle: Diagram
+cqCamelPartDescription: Camel Route Diagram rendering
+cqExtensionPageTitle: Diagram
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 1e808479ee..36792ec1af 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -118,6 +118,7 @@
*** xref:reference/extensions/debezium-sqlserver.adoc[Debezium SQL Server
Connector]
*** xref:reference/extensions/debug.adoc[Debug]
*** xref:reference/extensions/djl.adoc[Deep Java Library]
+*** xref:reference/extensions/diagram.adoc[Diagram]
*** xref:reference/extensions/digitalocean.adoc[DigitalOcean]
*** xref:reference/extensions/direct.adoc[Direct]
*** xref:reference/extensions/disruptor.adoc[Disruptor]
diff --git a/docs/modules/ROOT/pages/reference/extensions/diagram.adoc
b/docs/modules/ROOT/pages/reference/extensions/diagram.adoc
new file mode 100644
index 0000000000..d5b3af232b
--- /dev/null
+++ b/docs/modules/ROOT/pages/reference/extensions/diagram.adoc
@@ -0,0 +1,41 @@
+// Do not edit directly!
+// This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+[id="extensions-diagram"]
+= Diagram
+:linkattrs:
+:cq-artifact-id: camel-quarkus-diagram
+:cq-native-supported: false
+:cq-status: Preview
+:cq-status-deprecation: Preview
+:cq-description: Camel Route Diagram Dev UI
+:cq-deprecated: false
+:cq-jvm-since: 3.38.0
+:cq-native-since: n/a
+
+ifeval::[{doc-show-badges} == true]
+[.badges]
+[.badge-key]##JVM since##[.badge-supported]##3.38.0##
[.badge-key]##Native##[.badge-unsupported]##unsupported##
+endif::[]
+
+Camel Route Diagram Dev UI
+
+[id="extensions-diagram-whats-inside"]
+== What's inside
+
+* xref:{cq-camel-components}:others:diagram.adoc[Diagram]
+
+Please refer to the above link for usage and configuration details.
+
+[id="extensions-diagram-maven-coordinates"]
+== Maven coordinates
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+</dependency>
+----
+ifeval::[{doc-show-user-guide-link} == true]
+Check the xref:user-guide/index.adoc[User guide] for more information about
writing Camel Quarkus applications.
+endif::[]
diff --git
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/devui/CamelCoreDevConsoleProcessor.java
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/devui/CamelCoreDevConsoleProcessor.java
index b0b6ba43f4..dabc356296 100644
---
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/devui/CamelCoreDevConsoleProcessor.java
+++
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/devui/CamelCoreDevConsoleProcessor.java
@@ -47,6 +47,11 @@ public class CamelCoreDevConsoleProcessor {
.icon("font-awesome-solid:gear")
.componentLink("qwc-camel-core-context.js"));
+ cardPageBuildItem.addPage(Page.webComponentPageBuilder()
+ .title("Diagram")
+ .icon("font-awesome-solid:sitemap")
+ .componentLink("qwc-camel-core-diagram.js"));
+
cardPageBuildItem.addPage(Page.webComponentPageBuilder()
.title("Events")
.icon("font-awesome-solid:bolt-lightning")
diff --git
a/extensions-core/core/deployment/src/main/resources/dev-ui/qwc-camel-core-diagram.js
b/extensions-core/core/deployment/src/main/resources/dev-ui/qwc-camel-core-diagram.js
new file mode 100644
index 0000000000..d083bda6a5
--- /dev/null
+++
b/extensions-core/core/deployment/src/main/resources/dev-ui/qwc-camel-core-diagram.js
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { css, html, LitElement } from 'lit';
+import '@vaadin/checkbox';
+import '@vaadin/horizontal-layout';
+import '@vaadin/tabs';
+
+export class QwcCamelCoreDiagram extends LitElement {
+
+ static styles = css`
+ :host {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ overflow: auto;
+ }
+
+ .controls {
+ padding: 8px 16px;
+ flex-shrink: 0;
+ }
+
+ .diagram-container {
+ flex: 1;
+ padding: 0 16px 16px;
+ min-height: 0;
+ overflow: auto;
+ }
+
+ camel-route-diagram,
+ camel-topology-diagram {
+ --crd-bg: #ffffff;
+ --crd-fg: #1e293b;
+ --crd-edge: #94a3b8;
+ --ctd-bg: #ffffff;
+ --ctd-fg: #1e293b;
+ --ctd-edge: #94a3b8;
+ }
+ `;
+
+ static properties = {
+ _mode: { state: true },
+ _autoRefresh: { state: true },
+ _loaded: { state: true },
+ _error: { state: true },
+ };
+
+ constructor() {
+ super();
+ this._mode = 'route';
+ this._autoRefresh = true;
+ this._loaded = false;
+ this._error = null;
+ this._loadWebComponents();
+ }
+
+ _getNonAppRoot() {
+ const pathname = window.location.pathname;
+ const idx = pathname.indexOf('dev-ui/');
+ return idx >= 0 ? pathname.substring(0, idx) : '/q/';
+ }
+
+ _loadWebComponents() {
+ Promise.all([
+ import('/camel/diagram/camel-route-diagram.js'),
+ import('/camel/diagram/camel-topology-diagram.js'),
+ ]).then(() => {
+ this._loaded = true;
+ }).catch(err => {
+ console.error('Failed to load Camel diagram web components', err);
+ this._error = 'Failed to load diagram components.';
+ });
+ }
+
+ _getRefreshInterval() {
+ return this._autoRefresh ? '5000' : '0';
+ }
+
+ render() {
+ if (this._error) {
+ return html`<p>${this._error}</p>`;
+ }
+
+ if (!this._loaded) {
+ return html`<p>Loading diagram...</p>`;
+ }
+
+ const basePath = this._getNonAppRoot() + 'camel/diagram/';
+
+ return html`
+ <vaadin-horizontal-layout class="controls" theme="spacing"
style="align-items: center;">
+ <vaadin-tabs @selected-changed=${e => {
+ this._mode = e.detail.value === 0 ? 'route' : 'topology';
+ }}>
+ <vaadin-tab>Routes</vaadin-tab>
+ <vaadin-tab>Topology</vaadin-tab>
+ </vaadin-tabs>
+ <vaadin-checkbox
+ label="Auto refresh"
+ ?checked="${this._autoRefresh}"
+ @change=${e => { this._autoRefresh = e.target.checked;
}}>
+ </vaadin-checkbox>
+ </vaadin-horizontal-layout>
+ <div class="diagram-container">
+ ${this._mode === 'route'
+ ? html`<camel-route-diagram
+ src="${basePath}route-structure"
+ refresh="${this._getRefreshInterval()}">
+ </camel-route-diagram>`
+ : html`<camel-topology-diagram
+ src="${basePath}route-topology"
+ refresh="${this._getRefreshInterval()}">
+ </camel-topology-diagram>`
+ }
+ </div>
+ `;
+ }
+}
+
+customElements.define('qwc-camel-core-diagram', QwcCamelCoreDiagram);
diff --git a/extensions-core/core/runtime/pom.xml
b/extensions-core/core/runtime/pom.xml
index ea5d536f1c..911a7c3ba6 100644
--- a/extensions-core/core/runtime/pom.xml
+++ b/extensions-core/core/runtime/pom.xml
@@ -104,6 +104,7 @@
<conditionalDevDependencies>
<artifact>org.apache.camel.quarkus:camel-quarkus-cli-connector:${project.version}</artifact>
<artifact>org.apache.camel.quarkus:camel-quarkus-debug:${project.version}</artifact>
+
<artifact>org.apache.camel.quarkus:camel-quarkus-diagram:${project.version}</artifact>
</conditionalDevDependencies>
</configuration>
</plugin>
diff --git a/extensions-jvm/diagram/deployment/pom.xml
b/extensions-jvm/diagram/deployment/pom.xml
new file mode 100644
index 0000000000..bf0d932d26
--- /dev/null
+++ b/extensions-jvm/diagram/deployment/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram-parent</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-diagram-deployment</artifactId>
+ <name>Camel Quarkus :: Diagram :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-console-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions-jvm/diagram/deployment/src/main/java/org/apache/camel/quarkus/component/diagram/deployment/DiagramProcessor.java
b/extensions-jvm/diagram/deployment/src/main/java/org/apache/camel/quarkus/component/diagram/deployment/DiagramProcessor.java
new file mode 100644
index 0000000000..e4af1a5243
--- /dev/null
+++
b/extensions-jvm/diagram/deployment/src/main/java/org/apache/camel/quarkus/component/diagram/deployment/DiagramProcessor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.diagram.deployment;
+
+import java.util.function.Consumer;
+
+import io.quarkus.deployment.IsDevelopment;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.BuildSteps;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
+import io.quarkus.vertx.http.deployment.RouteBuildItem;
+import io.vertx.core.Handler;
+import io.vertx.ext.web.Route;
+import io.vertx.ext.web.RoutingContext;
+import org.apache.camel.quarkus.component.diagram.CamelDiagramRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem;
+
+@BuildSteps(onlyIf = IsDevelopment.class)
+class DiagramProcessor {
+ private static final String FEATURE = "camel-diagram";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ @Record(ExecutionTime.RUNTIME_INIT)
+ void createDiagramRoute(
+ CamelContextBuildItem camelContext,
+ NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
+ BuildProducer<RouteBuildItem> routes,
+ CamelDiagramRecorder recorder) {
+
+ Consumer<Route> route = recorder.route();
+ Handler<RoutingContext> handler =
recorder.getHandler(camelContext.getCamelContext());
+
+ routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
+ .management()
+ .routeFunction("camel/diagram/:id", route)
+ .handler(handler)
+ .build());
+ }
+}
diff --git a/extensions-jvm/diagram/pom.xml b/extensions-jvm/diagram/pom.xml
new file mode 100644
index 0000000000..2c252e13f9
--- /dev/null
+++ b/extensions-jvm/diagram/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-extensions-jvm</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-diagram-parent</artifactId>
+ <name>Camel Quarkus :: Diagram</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions-jvm/diagram/runtime/pom.xml
b/extensions-jvm/diagram/runtime/pom.xml
new file mode 100644
index 0000000000..7a3cf5bf1d
--- /dev/null
+++ b/extensions-jvm/diagram/runtime/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram-parent</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-diagram</artifactId>
+ <name>Camel Quarkus :: Diagram :: Runtime</name>
+ <description>Camel Route Diagram Dev UI</description>
+
+ <properties>
+ <camel.quarkus.jvmSince>3.38.0</camel.quarkus.jvmSince>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-diagram</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions-jvm/diagram/runtime/src/main/java/org/apache/camel/quarkus/component/diagram/CamelDiagramRecorder.java
b/extensions-jvm/diagram/runtime/src/main/java/org/apache/camel/quarkus/component/diagram/CamelDiagramRecorder.java
new file mode 100644
index 0000000000..3bca2a9fcc
--- /dev/null
+++
b/extensions-jvm/diagram/runtime/src/main/java/org/apache/camel/quarkus/component/diagram/CamelDiagramRecorder.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.diagram;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Consumer;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import io.vertx.core.Handler;
+import io.vertx.ext.web.Route;
+import io.vertx.ext.web.RoutingContext;
+import org.apache.camel.CamelContext;
+import org.apache.camel.console.DevConsole;
+import org.apache.camel.console.DevConsoleRegistry;
+import org.apache.camel.util.json.Jsoner;
+
+@Recorder
+public class CamelDiagramRecorder {
+
+ public Consumer<Route> route() {
+ return new Consumer<Route>() {
+ @Override
+ public void accept(Route route) {
+ // No content type restriction — handler negotiates based on
Accept header
+ }
+ };
+ }
+
+ public Handler<RoutingContext> getHandler(RuntimeValue<CamelContext>
contextRuntimeValue) {
+ CamelContext context = contextRuntimeValue.getValue();
+ DevConsoleRegistry devConsoleRegistry =
context.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class);
+ return new CamelDiagramHandler(devConsoleRegistry);
+ }
+
+ static final class CamelDiagramHandler implements Handler<RoutingContext> {
+ private final DevConsoleRegistry devConsoleRegistry;
+
+ CamelDiagramHandler(DevConsoleRegistry devConsoleRegistry) {
+ this.devConsoleRegistry = devConsoleRegistry;
+ }
+
+ @Override
+ public void handle(RoutingContext ctx) {
+ if (devConsoleRegistry == null || !devConsoleRegistry.isEnabled())
{
+ ctx.response().setStatusCode(503).end();
+ return;
+ }
+
+ String id = ctx.pathParam("id");
+ if (id == null || id.isEmpty()) {
+ ctx.response().setStatusCode(404).end();
+ return;
+ }
+
+ DevConsole console = devConsoleRegistry.stream()
+ .filter(c -> c.getId().equals(id))
+ .findFirst()
+ .orElse(null);
+
+ if (console == null) {
+ ctx.response().setStatusCode(404).end();
+ return;
+ }
+
+ Map<String, Object> options = new HashMap<>();
+ ctx.queryParams().forEach(entry -> options.put(entry.getKey(),
entry.getValue()));
+
+ String accept = ctx.request().getHeader("Accept");
+ boolean wantsJson = accept != null &&
accept.contains("application/json");
+ String format = ctx.queryParams().get("format");
+ boolean wantsHtml = "html".equals(format);
+
+ if (wantsJson &&
console.supportMediaType(DevConsole.MediaType.JSON)) {
+ Object result = console.call(DevConsole.MediaType.JSON,
options);
+ if (result != null) {
+ ctx.response()
+ .putHeader("Content-Type", "application/json")
+ .end(Jsoner.serialize(result));
+ } else {
+ ctx.response().setStatusCode(204).end();
+ }
+ } else if (console.supportMediaType(DevConsole.MediaType.TEXT)) {
+ Object result = console.call(DevConsole.MediaType.TEXT,
options);
+ if (result != null) {
+ String contentType = wantsHtml ? "text/html" :
"text/plain";
+ ctx.response()
+ .putHeader("Content-Type", contentType)
+ .end(result.toString());
+ } else {
+ ctx.response().setStatusCode(204).end();
+ }
+ } else {
+ ctx.response().setStatusCode(406).end();
+ }
+ }
+ }
+}
diff --git
a/extensions-jvm/diagram/runtime/src/main/resources/META-INF/quarkus-extension.yaml
b/extensions-jvm/diagram/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000000..53f593d475
--- /dev/null
+++
b/extensions-jvm/diagram/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel Diagram"
+description: "Camel Route Diagram Dev UI"
+metadata:
+ icon-url:
"https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
+ sponsor: "Apache Software Foundation"
+ unlisted: true
+ guide:
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/diagram.html"
+ categories:
+ - "integration"
+ status: "stable"
+ integrates:
+ - name: "Camel"
+ artifact: "org.apache.camel:camel-base"
+ version: "${camel.version}"
\ No newline at end of file
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 5e43076f26..40d1fb24d4 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -51,6 +51,7 @@
<module>console</module>
<module>couchbase</module>
<module>dfdl</module>
+ <module>diagram</module>
<module>djl</module>
<module>dns</module>
<module>drill</module>
diff --git a/integration-tests-jvm/diagram/pom.xml
b/integration-tests-jvm/diagram/pom.xml
new file mode 100644
index 0000000000..4cbca4e398
--- /dev/null
+++ b/integration-tests-jvm/diagram/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-diagram</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Diagram</name>
+ <description>Integration tests for Camel Quarkus Diagram
extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit-internal</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>virtualDependencies</id>
+ <activation>
+ <property>
+ <name>!noVirtualDependencies</name>
+ </property>
+ </activation>
+ <dependencies>
+ <!-- The following dependencies guarantee that this module is
built after them. You can update them by running `mvn process-resources
-Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-timer-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
diff --git
a/integration-tests-jvm/diagram/src/main/java/org/apache/camel/quarkus/component/diagram/it/DiagramRoutes.java
b/integration-tests-jvm/diagram/src/main/java/org/apache/camel/quarkus/component/diagram/it/DiagramRoutes.java
new file mode 100644
index 0000000000..ded1290e47
--- /dev/null
+++
b/integration-tests-jvm/diagram/src/main/java/org/apache/camel/quarkus/component/diagram/it/DiagramRoutes.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.diagram.it;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class DiagramRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("timer:diagram-test")
+ .routeId("diagram-test-route")
+ .log("Diagram test route");
+ }
+}
diff --git
a/integration-tests-jvm/diagram/src/test/java/org/apache/camel/quarkus/component/diagram/it/DiagramTest.java
b/integration-tests-jvm/diagram/src/test/java/org/apache/camel/quarkus/component/diagram/it/DiagramTest.java
new file mode 100644
index 0000000000..eb6676a931
--- /dev/null
+++
b/integration-tests-jvm/diagram/src/test/java/org/apache/camel/quarkus/component/diagram/it/DiagramTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.diagram.it;
+
+import io.quarkus.test.QuarkusDevModeTest;
+import io.restassured.RestAssured;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.emptyString;
+import static org.hamcrest.Matchers.not;
+
+class DiagramTest {
+
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
+ .addClass(DiagramRoutes.class)
+ .addAsResource(new
StringAsset("quarkus.camel.console.enabled=true\n"), "application.properties"));
+
+ @Test
+ void routeDiagramHtml() {
+ RestAssured.given()
+ .accept("text/html")
+ .queryParam("format", "html")
+ .queryParam("mode", "route")
+ .when()
+ .get("/q/camel/diagram/route-diagram")
+ .then()
+ .statusCode(200)
+ .contentType("text/html")
+ .body(containsString("<html"),
+ containsString("camel-route-diagram"));
+ }
+
+ @Test
+ void routeStructureJson() {
+ RestAssured.given()
+ .accept("application/json")
+ .when()
+ .get("/q/camel/diagram/route-structure")
+ .then()
+ .statusCode(200)
+ .contentType("application/json")
+ .body(containsString("routes"),
+ containsString("diagram-test-route"));
+ }
+
+ @Test
+ void routeTopologyJson() {
+ RestAssured.given()
+ .accept("application/json")
+ .when()
+ .get("/q/camel/diagram/route-topology")
+ .then()
+ .statusCode(200)
+ .contentType("application/json")
+ .body(containsString("nodes"),
+ not(emptyString()));
+ }
+
+ @Test
+ void nonExistentConsole() {
+ RestAssured.get("/q/camel/diagram/nonexistent")
+ .then()
+ .statusCode(404);
+ }
+}
diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml
index 03ab827557..d25d4343e0 100644
--- a/integration-tests-jvm/pom.xml
+++ b/integration-tests-jvm/pom.xml
@@ -50,6 +50,7 @@
<module>controlbus-statistics</module>
<module>couchbase</module>
<module>dfdl</module>
+ <module>diagram</module>
<module>djl</module>
<module>dns</module>
<module>drill</module>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index a6df497aca..f125c2574a 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -1106,6 +1106,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-diagram</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-digitalocean</artifactId>
@@ -4377,6 +4382,16 @@
<artifactId>camel-quarkus-dfdl-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-digitalocean</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml
b/poms/bom/src/main/generated/flattened-full-pom.xml
index 743f8f0968..c20c5a79e5 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -1019,6 +1019,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-diagram</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>4.21.0</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>camel-digitalocean</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
@@ -4262,6 +4267,16 @@
<artifactId>camel-quarkus-dfdl-deployment</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-quarkus-diagram</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-quarkus-diagram-deployment</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>camel-quarkus-digitalocean</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index b3eb29916c..5f5726acf5 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -1019,6 +1019,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-diagram</artifactId>
+ <version>4.21.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-digitalocean</artifactId>
@@ -4236,6 +4241,16 @@
<artifactId>camel-quarkus-dfdl-deployment</artifactId>
<version>3.38.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-diagram-deployment</artifactId>
+ <version>3.38.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-digitalocean</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
index dd49e35be9..bcb836ebb5 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -1019,6 +1019,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-diagram</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>4.21.0</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>camel-digitalocean</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
@@ -4236,6 +4241,16 @@
<artifactId>camel-quarkus-dfdl-deployment</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-quarkus-diagram</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>camel-quarkus-diagram-deployment</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>3.38.0-SNAPSHOT</version><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>camel-quarkus-digitalocean</artifactId><!--
org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->