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 2024/03/20 16:31:20 UTC

(camel-spring-boot) branch main updated: CAMEL-20548: include a capability section to advertise which artifact provides a specific feature (#1115)

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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new b7f772c36c7 CAMEL-20548: include a capability section to advertise which artifact provides a specific feature (#1115)
b7f772c36c7 is described below

commit b7f772c36c7a7a0060b195e385ef71bd73516f88
Author: Luca Burgazzoli <lb...@users.noreply.github.com>
AuthorDate: Wed Mar 20 17:31:15 2024 +0100

    CAMEL-20548: include a capability section to advertise which artifact provides a specific feature (#1115)
---
 .../springboot/catalog/SpringBootRuntimeProvider.java | 19 +++++++++++++++----
 .../camel/springboot/catalog/capabilities.properties  | 18 ++++++++++++++++++
 .../catalog/SpringBootRuntimeProviderTest.java        | 18 ++++++++++++++++++
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/catalog/camel-catalog-provider-springboot/src/main/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProvider.java b/catalog/camel-catalog-provider-springboot/src/main/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProvider.java
index a35fad2f929..2f4ce19af88 100644
--- a/catalog/camel-catalog-provider-springboot/src/main/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProvider.java
+++ b/catalog/camel-catalog-provider-springboot/src/main/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProvider.java
@@ -19,10 +19,10 @@ package org.apache.camel.springboot.catalog;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.RuntimeProvider;
@@ -48,6 +48,7 @@ public class SpringBootRuntimeProvider implements RuntimeProvider {
     private static final String CONSOLES_CATALOG = "org/apache/camel/springboot/catalog/dev-consoles.properties";
     private static final String OTHER_CATALOG = "org/apache/camel/springboot/catalog/others.properties";
     private static final String BEAN_CATALOG = "org/apache/camel/springboot/catalog/beans.properties";
+    private static final String CAPABILITIES_CATALOG = "org/apache/camel/springboot/catalog/capabilities.properties";
 
     private CamelCatalog camelCatalog;
 
@@ -146,10 +147,20 @@ public class SpringBootRuntimeProvider implements RuntimeProvider {
         return findNames(BEAN_CATALOG);
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     public Map<String, String> findCapabilities() {
-        // TODO: add SB specific capabilities
-        return Collections.EMPTY_MAP;
+        final Properties properties = new Properties();
+
+        try (InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(CAPABILITIES_CATALOG)) {
+            if (is != null) {
+                properties.load(is);
+            }
+        } catch (IOException e) {
+            // ignore
+        }
+
+        return new TreeMap<>((Map<String, String>) (Map) properties);
     }
 
     private List<String> findNames(String pathToPropertyCatalogDescriptor) {
diff --git a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/capabilities.properties b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/capabilities.properties
new file mode 100644
index 00000000000..bdc93b6f27b
--- /dev/null
+++ b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/capabilities.properties
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+platform-http=component/platform-http
\ No newline at end of file
diff --git a/catalog/camel-catalog-provider-springboot/src/test/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProviderTest.java b/catalog/camel-catalog-provider-springboot/src/test/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProviderTest.java
index 7b3739c4ec8..833783a6085 100644
--- a/catalog/camel-catalog-provider-springboot/src/test/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProviderTest.java
+++ b/catalog/camel-catalog-provider-springboot/src/test/java/org/apache/camel/springboot/catalog/SpringBootRuntimeProviderTest.java
@@ -17,9 +17,13 @@
 package org.apache.camel.springboot.catalog;
 
 import java.util.List;
+import java.util.Optional;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
@@ -134,4 +138,18 @@ public class SpringBootRuntimeProviderTest {
         assertTrue(json.contains("camel-lra-starter"));
     }
 
+    @Test
+    public void capabilities() {
+        List<String> list = catalog.findCapabilityNames();
+        Assertions.assertEquals(1, list.size());
+
+        Optional<EntityRef> ref = catalog.findCapabilityRef("platform-http");
+        Assertions.assertTrue(ref.isPresent());
+        Assertions.assertEquals(Kind.component, ref.get().kind());
+        Assertions.assertEquals("platform-http", ref.get().name());
+
+        Optional<EntityRef> ref2 = catalog.findCapabilityRef("not-implemented");
+        Assertions.assertFalse(ref2.isPresent());
+    }
+
 }