You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/12/30 12:04:45 UTC

[camel] 29/30: CAMEL-17384: Developer Console SPI

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch console
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b49e56ee56c3c465aaeab68dd71a1e2590e4bd4f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 30 10:39:28 2021 +0100

    CAMEL-17384: Developer Console SPI
---
 .../camel/catalog/console/CatalogConsole.java      | 27 ++++++++++++++++++++++
 dsl/camel-kamelet-main/pom.xml                     |  4 ++++
 2 files changed, 31 insertions(+)

diff --git a/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java b/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java
index 183d083..068717c 100644
--- a/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java
+++ b/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java
@@ -23,10 +23,12 @@ import org.apache.camel.catalog.DefaultCamelCatalog;
 import org.apache.camel.impl.console.AbstractDevConsole;
 import org.apache.camel.spi.annotations.DevConsole;
 import org.apache.camel.tooling.model.ArtifactModel;
+import org.apache.camel.tooling.model.OtherModel;
 
 @DevConsole("catalog")
 public class CatalogConsole extends AbstractDevConsole {
 
+    private static final String CP = System.getProperty("java.class.path");
     private final CamelCatalog catalog = new DefaultCamelCatalog(true);
 
     public CatalogConsole() {
@@ -45,9 +47,34 @@ public class CatalogConsole extends AbstractDevConsole {
         sb.append("\n\nData Formats:\n");
         getCamelContext().getDataFormatNames().forEach(n -> appendModel(catalog.dataFormatModel(n), sb));
 
+        // misc is harder to find as we need to find them via classpath
+        sb.append("\n\nMiscellaneous Components:\n");
+        String[] cp = CP.split("[:|;]");
+        String suffix = "-" + getCamelContext().getVersion() + ".jar";
+        for (String c : cp) {
+            if (c.endsWith(suffix)) {
+                int pos = Math.max(c.lastIndexOf("/"), c.lastIndexOf("\\"));
+                if (pos > 0) {
+                    c = c.substring(pos + 1, c.length() - suffix.length());
+                    appendModel(findOtherModel(c), sb);
+                }
+            }
+        }
+
         return sb.toString();
     }
 
+    private ArtifactModel findOtherModel(String artifactId) {
+        // is it a mist component
+        for (String name : catalog.findOtherNames()) {
+            OtherModel model = catalog.otherModel(name);
+            if (model != null && model.getArtifactId().equals(artifactId)) {
+                return model;
+            }
+        }
+        return null;
+    }
+
     private static void appendModel(ArtifactModel<?> model, StringBuilder sb) {
         if (model != null) {
             String level = model.getSupportLevel().toString();
diff --git a/dsl/camel-kamelet-main/pom.xml b/dsl/camel-kamelet-main/pom.xml
index cd69ecf..94e4f16 100644
--- a/dsl/camel-kamelet-main/pom.xml
+++ b/dsl/camel-kamelet-main/pom.xml
@@ -44,6 +44,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
+            <artifactId>camel-debug</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
             <artifactId>camel-health</artifactId>
         </dependency>
         <dependency>