You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/07/28 05:11:30 UTC

[camel] branch main created (now 6682a90)

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

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


      at 6682a90  CAMEL-16822: CamelContext API - getComponentNames and getLanguageNames changed to return Set instead of List

This branch includes the following new commits:

     new 6682a90  CAMEL-16822: CamelContext API - getComponentNames and getLanguageNames changed to return Set instead of List

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[camel] 01/01: CAMEL-16822: CamelContext API - getComponentNames and getLanguageNames changed to return Set instead of List

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6682a900e5d615bffa8cc2c9bfe1738bd882f490
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jul 28 06:59:11 2021 +0200

    CAMEL-16822: CamelContext API - getComponentNames and getLanguageNames changed to return Set instead of List
---
 .../src/main/java/org/apache/camel/CamelContext.java         |  4 ++--
 .../org/apache/camel/impl/engine/AbstractCamelContext.java   | 12 ++++++------
 .../org/apache/camel/impl/lw/LightweightCamelContext.java    |  4 ++--
 .../apache/camel/impl/lw/LightweightRuntimeCamelContext.java |  6 +++---
 .../modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc      |  5 +++++
 5 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
index 387c071..31843c0 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java
@@ -385,7 +385,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
      *
      * @return a readonly list with the names of the components
      */
-    List<String> getComponentNames();
+    Set<String> getComponentNames();
 
     /**
      * Removes a previously added component.
@@ -776,7 +776,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
      * @deprecated not in use
      */
     @Deprecated
-    List<String> getLanguageNames();
+    Set<String> getLanguageNames();
 
     /**
      * Creates a new {@link ProducerTemplate} which is <b>started</b> and therefore ready to use right away.
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index dbc792c..6f9026d 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2891,8 +2891,8 @@ public abstract class AbstractCamelContext extends BaseService
         // output how many instances of the same component class are in use, as multiple instances is potential a mistake
         if (LOG.isInfoEnabled()) {
             Map<Class<?>, Set<String>> counters = new LinkedHashMap<>();
-            List<String> cnames = getComponentNames();
-            Collections.sort(cnames);
+            // use TreeSet to sort the names
+            Set<String> cnames = new TreeSet<>(getComponentNames());
             for (String sourceName : cnames) {
                 Class<?> source = getComponent(sourceName).getClass();
                 if (!counters.containsKey(source)) {
@@ -3885,13 +3885,13 @@ public abstract class AbstractCamelContext extends BaseService
     }
 
     @Override
-    public List<String> getComponentNames() {
-        return new ArrayList<>(components.keySet());
+    public Set<String> getComponentNames() {
+        return Collections.unmodifiableSet(components.keySet());
     }
 
     @Override
-    public List<String> getLanguageNames() {
-        return new ArrayList<>(languages.keySet());
+    public Set<String> getLanguageNames() {
+        return Collections.unmodifiableSet(languages.keySet());
     }
 
     @Override
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
index 14cd80c..e56983b 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
@@ -446,7 +446,7 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
     }
 
     @Override
-    public List<String> getComponentNames() {
+    public Set<String> getComponentNames() {
         return delegate.getComponentNames();
     }
 
@@ -658,7 +658,7 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
 
     @Override
     @Deprecated
-    public List<String> getLanguageNames() {
+    public Set<String> getLanguageNames() {
         return delegate.getLanguageNames();
     }
 
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
index e807148..fc84451 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightRuntimeCamelContext.java
@@ -743,8 +743,8 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
     }
 
     @Override
-    public List<String> getComponentNames() {
-        return new ArrayList<>(components.keySet());
+    public Set<String> getComponentNames() {
+        return Collections.unmodifiableSet(components.keySet());
     }
 
     @Override
@@ -952,7 +952,7 @@ public class LightweightRuntimeCamelContext implements ExtendedCamelContext, Cat
     }
 
     @Override
-    public List<String> getLanguageNames() {
+    public Set<String> getLanguageNames() {
         throw new UnsupportedOperationException();
     }
 
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
index 2d75a3f..8b5d650 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_12.adoc
@@ -6,6 +6,11 @@ from both 3.0 to 3.1 and 3.1 to 3.2.
 
 == Upgrading Camel 3.11 to 3.12
 
+=== API changes
+
+The method `getComponentNames` and `getLanguageNames` on `CamelContext` has changed to
+return `Set<String>` instead of `List<String>`.
+
 === Data Formats
 
 The `camel-asn1` data format has renamed the option `clazzName` to `unmarshalType`.