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.git


The following commit(s) were added to refs/heads/main by this push:
     new 2f8212d  Summary (#7243)
2f8212d is described below

commit 2f8212d6d1ffd19d512555303850e163592d454a
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Mar 22 13:57:11 2022 +0100

    Summary (#7243)
    
    CAMEL-17831: camel-main - Auto configuration summary (show from where the 
option was taken)
    CAMEL-17837 camel-main - Loading properties from multiple PropertiesSource 
- Keys with difference case styles
    
    * Update 
core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java
    Co-authored-by: Nicolas Filotto <[email protected]>
---
 .../main/camel-main-configuration-metadata.json    |   2 +-
 .../org/apache/camel/spi/PropertiesComponent.java  |  32 +-
 .../properties/ClasspathPropertiesSource.java      |   7 +-
 .../component/properties/FilePropertiesSource.java |   7 +-
 .../component/properties/PropertiesComponent.java  | 100 +++++-
 .../camel-main-configuration-metadata.json         |   2 +-
 core/camel-main/src/main/docs/main.adoc            |   2 +-
 .../org/apache/camel/main/BaseMainSupport.java     | 359 +++++++++++----------
 .../camel/main/DefaultConfigurationProperties.java |  15 +-
 .../java/org/apache/camel/main/MainHelper.java     |  47 ++-
 .../camel/main/MainSupportModelConfigurer.java     |  15 +-
 ...dProperties.java => BaseOrderedProperties.java} |  18 +-
 .../camel/util/OrderedLocationProperties.java      |  73 +++++
 .../org/apache/camel/util/OrderedProperties.java   |  93 +-----
 .../apache/camel/dsl/modeline/DependencyTrait.java |   3 +-
 .../org/apache/camel/dsl/modeline/EnvTrait.java    |   3 +-
 .../apache/camel/dsl/modeline/ModelineParser.java  |   6 +-
 .../org/apache/camel/dsl/modeline/NameTrait.java   |   3 +-
 .../apache/camel/dsl/modeline/PropertyTrait.java   |  54 +++-
 .../java/org/apache/camel/dsl/modeline/Trait.java  |  10 +-
 20 files changed, 517 insertions(+), 334 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 6050deb..71c527a 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -32,7 +32,7 @@
     { "name": "camel.main.consumerTemplateCacheSize", "description": "Consumer 
template endpoints cache size.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", 
"javaType": "int", "defaultValue": 1000 },
     { "name": "camel.main.debugging", "description": "Sets whether debugging 
is enabled or not. Default is false.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.main.devConsoleEnabled", "description": "Whether to 
enable developer console (requires camel-console on classpath). The developer 
console is only for assisting during development. This is NOT for production 
usage.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", 
"type": "boolean", "javaType": "boolean", "defaultValue": "false" },
-    { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled 
then Camel will during startup dump all loaded routes (incl rests and route 
templates) represented as XML DSL into the log. This is intended for trouble 
shooting or to assist during development. Sensitive information that may be 
configured in the route endpoints could potentially be included in the dump 
output and is therefore not recommended to be used for production usage. This 
requires to have camel-xml-jaxb  [...]
+    { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled 
then Camel will during startup dump all loaded routes (incl rests and route 
templates) represented as XML DSL into the log. This is intended for trouble 
shooting or to assist during development. Sensitive information that may be 
configured in the route endpoints could potentially be included in the dump 
output and is therefore not recommended being used for production usage. This 
requires to have camel-xml-jaxb  [...]
     { "name": "camel.main.durationHitExitCode", "description": "Sets the exit 
code for the application if duration was hit", "sourceType": 
"org.apache.camel.main.MainConfigurationProperties", "type": "integer", 
"javaType": "int" },
     { "name": "camel.main.durationMaxAction", "description": "Controls whether 
the Camel application should shutdown the JVM, or stop all routes, when 
duration max is triggered.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "shutdown", "enum": [ 
"shutdown", "stop" ] },
     { "name": "camel.main.durationMaxIdleSeconds", "description": "To specify 
for how long time in seconds Camel can be idle before automatic terminating the 
JVM. You can use this to run Camel for a short while.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", 
"javaType": "int" },
diff --git 
a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java 
b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java
index c7ab968..391b6dd 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java
@@ -20,6 +20,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.function.Function;
 import java.util.function.Predicate;
 
 import org.apache.camel.StaticService;
@@ -101,14 +102,10 @@ public interface PropertiesComponent extends 
StaticService {
 
     /**
      * Loads the properties from the default locations and sources filtering 
them out according to a predicate.
-     * </p>
      *
      * <pre>
-     * {
-     *     &#64;code
-     *     PropertiesComponent pc = getPropertiesComponent();
-     *     Properties props = pc.loadProperties(key -> 
key.startsWith("camel.component.seda"));
-     * }
+     * PropertiesComponent pc = getPropertiesComponent();
+     * Properties props = pc.loadProperties(key -> 
key.startsWith("camel.component.seda"));
      * </pre>
      *
      * @param  filter the predicate used to filter out properties based on the 
key.
@@ -117,15 +114,26 @@ public interface PropertiesComponent extends 
StaticService {
     Properties loadProperties(Predicate<String> filter);
 
     /**
+     * Loads the properties from the default locations and sources filtering 
them out according to a predicate, and maps
+     * the key using the key mapper.
+     *
+     * <pre>
+     * PropertiesComponent pc = getPropertiesComponent();
+     * Properties props = pc.loadProperties(key -> 
key.startsWith("camel.component.seda"), StringHelper::dashToCamelCase);
+     * </pre>
+     *
+     * @param  filter    the predicate used to filter out properties based on 
the key.
+     * @param  keyMapper to map keys
+     * @return           the properties loaded.
+     */
+    Properties loadProperties(Predicate<String> filter, Function<String, 
String> keyMapper);
+
+    /**
      * Loads the properties from the default locations and sources filtering 
them out according to a predicate.
-     * </p>
      *
      * <pre>
-     * {
-     *     &#64;code
-     *     PropertiesComponent pc = getPropertiesComponent();
-     *     Map<String, Object> props = pc.loadPropertiesAsMap(key -> 
key.startsWith("camel.component.seda"));
-     * }
+     * PropertiesComponent pc = getPropertiesComponent();
+     * Map props = pc.loadPropertiesAsMap(key -> 
key.startsWith("camel.component.seda"));
      * </pre>
      *
      * @param  filter the predicate used to filter out properties based on the 
key.
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/ClasspathPropertiesSource.java
 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/ClasspathPropertiesSource.java
index 4e4b208..7aba136 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/ClasspathPropertiesSource.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/ClasspathPropertiesSource.java
@@ -24,11 +24,12 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.Properties;
 
+import org.apache.camel.Ordered;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
 
-public class ClasspathPropertiesSource extends 
AbstractLocationPropertiesSource {
+public class ClasspathPropertiesSource extends 
AbstractLocationPropertiesSource implements Ordered {
 
     public ClasspathPropertiesSource(PropertiesComponent propertiesComponent, 
PropertiesLocation location) {
         super(propertiesComponent, location);
@@ -68,4 +69,8 @@ public class ClasspathPropertiesSource extends 
AbstractLocationPropertiesSource
         return answer;
     }
 
+    @Override
+    public int getOrder() {
+        return 200;
+    }
 }
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/FilePropertiesSource.java
 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/FilePropertiesSource.java
index e410116..7d63576 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/FilePropertiesSource.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/FilePropertiesSource.java
@@ -25,11 +25,12 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.Properties;
 
+import org.apache.camel.Ordered;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
 
-public class FilePropertiesSource extends AbstractLocationPropertiesSource {
+public class FilePropertiesSource extends AbstractLocationPropertiesSource 
implements Ordered {
 
     protected FilePropertiesSource(PropertiesComponent propertiesComponent, 
PropertiesLocation location) {
         super(propertiesComponent, location);
@@ -66,4 +67,8 @@ public class FilePropertiesSource extends 
AbstractLocationPropertiesSource {
         return answer;
     }
 
+    @Override
+    public int getOrder() {
+        return 100;
+    }
 }
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 471e191..7c0e2b3 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
@@ -44,6 +45,7 @@ import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.support.service.ServiceSupport;
 import org.apache.camel.util.FilePathResolver;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.OrderedLocationProperties;
 import org.apache.camel.util.OrderedProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -180,11 +182,11 @@ public class PropertiesComponent extends ServiceSupport
         // this method may be replaced by loadProperties(k -> true) but the 
underlying sources
         // may have some optimization for bulk load so let's keep it
 
-        Properties prop = new OrderedProperties();
+        OrderedLocationProperties prop = new OrderedLocationProperties();
 
         // use initial properties
         if (initialProperties != null) {
-            prop.putAll(initialProperties);
+            prop.putAll("initial", initialProperties);
         }
 
         if (!sources.isEmpty()) {
@@ -196,7 +198,14 @@ public class PropertiesComponent extends ServiceSupport
                 if (ps instanceof LoadablePropertiesSource) {
                     LoadablePropertiesSource lps = (LoadablePropertiesSource) 
ps;
                     Properties p = lps.loadProperties();
-                    prop.putAll(p);
+                    if (p instanceof OrderedLocationProperties) {
+                        prop.putAll((OrderedLocationProperties) p);
+                    } else if (ps instanceof LocationPropertiesSource) {
+                        String loc = ((LocationPropertiesSource) 
ps).getLocation().getPath();
+                        prop.putAll(loc, p);
+                    } else {
+                        prop.putAll(lps.getName(), p);
+                    }
                 }
             }
         }
@@ -204,9 +213,9 @@ public class PropertiesComponent extends ServiceSupport
         // use override properties
         if (overrideProperties != null) {
             // make a copy to avoid affecting the original properties
-            Properties override = new OrderedProperties();
+            OrderedLocationProperties override = new 
OrderedLocationProperties();
             override.putAll(prop);
-            override.putAll(overrideProperties);
+            override.putAll("override", overrideProperties);
             prop = override;
         }
 
@@ -215,13 +224,13 @@ public class PropertiesComponent extends ServiceSupport
 
     @Override
     public Properties loadProperties(Predicate<String> filter) {
-        Properties prop = new OrderedProperties();
+        OrderedLocationProperties prop = new OrderedLocationProperties();
 
         // use initial properties
         if (initialProperties != null) {
             for (String name : initialProperties.stringPropertyNames()) {
                 if (filter.test(name)) {
-                    prop.put(name, initialProperties.get(name));
+                    prop.put("initial", name, initialProperties.get(name));
                 }
             }
         }
@@ -235,7 +244,74 @@ public class PropertiesComponent extends ServiceSupport
                 if (ps instanceof LoadablePropertiesSource) {
                     LoadablePropertiesSource lps = (LoadablePropertiesSource) 
ps;
                     Properties p = lps.loadProperties(filter);
-                    prop.putAll(p);
+                    if (p instanceof OrderedLocationProperties) {
+                        prop.putAll((OrderedLocationProperties) p);
+                    } else if (ps instanceof LocationPropertiesSource) {
+                        String loc = ((LocationPropertiesSource) 
ps).getLocation().getPath();
+                        prop.putAll(loc, p);
+                    } else {
+                        prop.putAll(lps.getName(), p);
+                    }
+                }
+            }
+        }
+
+        // use override properties
+        if (overrideProperties != null) {
+            for (String name : overrideProperties.stringPropertyNames()) {
+                if (filter.test(name)) {
+                    prop.put("override", name, overrideProperties.get(name));
+                }
+            }
+        }
+
+        return prop;
+    }
+
+    @Override
+    public Properties loadProperties(Predicate<String> filter, 
Function<String, String> keyMapper) {
+        OrderedLocationProperties prop = new OrderedLocationProperties();
+
+        // use initial properties
+        if (initialProperties != null) {
+            for (String name : initialProperties.stringPropertyNames()) {
+                if (filter.test(name)) {
+                    Object value = initialProperties.get(name);
+                    name = keyMapper.apply(name);
+                    prop.put("initial", name, value);
+                }
+            }
+        }
+
+        if (!sources.isEmpty()) {
+            // sources are ordered according to {@link 
org.apache.camel.support.OrderComparator} so
+            // it is needed to iterate them in reverse order otherwise lower 
priority sources may
+            // override properties from higher priority ones
+            for (int i = sources.size(); i-- > 0;) {
+                PropertiesSource ps = sources.get(i);
+                if (ps instanceof LoadablePropertiesSource) {
+                    LoadablePropertiesSource lps = (LoadablePropertiesSource) 
ps;
+                    Properties p = lps.loadProperties(filter);
+                    if (p instanceof OrderedLocationProperties) {
+                        OrderedLocationProperties olp = 
(OrderedLocationProperties) p;
+                        for (String name : olp.stringPropertyNames()) {
+                            String loc = olp.getLocation(name);
+                            Object value = olp.getProperty(name);
+                            name = keyMapper.apply(name);
+                            prop.put(loc, name, value);
+                        }
+                    } else {
+                        String loc = lps.getName();
+                        if (ps instanceof LocationPropertiesSource) {
+                            LocationPropertiesSource olp = 
(LocationPropertiesSource) ps;
+                            loc = olp.getLocation().getPath();
+                        }
+                        for (String name : p.stringPropertyNames()) {
+                            Object value = p.getProperty(name);
+                            name = keyMapper.apply(name);
+                            prop.put(loc, name, value);
+                        }
+                    }
                 }
             }
         }
@@ -244,7 +320,9 @@ public class PropertiesComponent extends ServiceSupport
         if (overrideProperties != null) {
             for (String name : overrideProperties.stringPropertyNames()) {
                 if (filter.test(name)) {
-                    prop.put(name, overrideProperties.get(name));
+                    Object value = overrideProperties.get(name);
+                    name = keyMapper.apply(name);
+                    prop.put("override", name, value);
                 }
             }
         }
@@ -594,8 +672,10 @@ public class PropertiesComponent extends ServiceSupport
         CamelContextAware.trySetCamelContext(propertiesSource, 
getCamelContext());
         synchronized (lock) {
             sources.add(propertiesSource);
+            // resort after we add a new source
+            sources.sort(OrderedComparator.get());
             if (!isNew()) {
-                // if we have already initialized or started then we should 
also init the source
+                // if we have already initialized or started then also init 
the source
                 ServiceHelper.initService(propertiesSource);
             }
             if (isStarted()) {
diff --git 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 6050deb..71c527a 100644
--- 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -32,7 +32,7 @@
     { "name": "camel.main.consumerTemplateCacheSize", "description": "Consumer 
template endpoints cache size.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", 
"javaType": "int", "defaultValue": 1000 },
     { "name": "camel.main.debugging", "description": "Sets whether debugging 
is enabled or not. Default is false.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.main.devConsoleEnabled", "description": "Whether to 
enable developer console (requires camel-console on classpath). The developer 
console is only for assisting during development. This is NOT for production 
usage.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", 
"type": "boolean", "javaType": "boolean", "defaultValue": "false" },
-    { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled 
then Camel will during startup dump all loaded routes (incl rests and route 
templates) represented as XML DSL into the log. This is intended for trouble 
shooting or to assist during development. Sensitive information that may be 
configured in the route endpoints could potentially be included in the dump 
output and is therefore not recommended to be used for production usage. This 
requires to have camel-xml-jaxb  [...]
+    { "name": "camel.main.dumpRoutes", "description": "If dumping is enabled 
then Camel will during startup dump all loaded routes (incl rests and route 
templates) represented as XML DSL into the log. This is intended for trouble 
shooting or to assist during development. Sensitive information that may be 
configured in the route endpoints could potentially be included in the dump 
output and is therefore not recommended being used for production usage. This 
requires to have camel-xml-jaxb  [...]
     { "name": "camel.main.durationHitExitCode", "description": "Sets the exit 
code for the application if duration was hit", "sourceType": 
"org.apache.camel.main.MainConfigurationProperties", "type": "integer", 
"javaType": "int" },
     { "name": "camel.main.durationMaxAction", "description": "Controls whether 
the Camel application should shutdown the JVM, or stop all routes, when 
duration max is triggered.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "shutdown", "enum": [ 
"shutdown", "stop" ] },
     { "name": "camel.main.durationMaxIdleSeconds", "description": "To specify 
for how long time in seconds Camel can be idle before automatic terminating the 
JVM. You can use this to run Camel for a short while.", "sourceType": 
"org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", 
"javaType": "int" },
diff --git a/core/camel-main/src/main/docs/main.adoc 
b/core/camel-main/src/main/docs/main.adoc
index 2e83fd0..a1cfc1c 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -43,7 +43,7 @@ The camel.main supports 109 options, which are listed below.
 | *camel.main.consumerTemplate{zwsp}CacheSize* | Consumer template endpoints 
cache size. | 1000 | int
 | *camel.main.debugging* | Sets whether debugging is enabled or not. Default 
is false. | false | boolean
 | *camel.main.devConsoleEnabled* | Whether to enable developer console 
(requires camel-console on classpath). The developer console is only for 
assisting during development. This is NOT for production usage. | false | 
boolean
-| *camel.main.dumpRoutes* | If dumping is enabled then Camel will during 
startup dump all loaded routes (incl rests and route templates) represented as 
XML DSL into the log. This is intended for trouble shooting or to assist during 
development. Sensitive information that may be configured in the route 
endpoints could potentially be included in the dump output and is therefore not 
recommended to be used for production usage. This requires to have 
camel-xml-jaxb on the classpath to be able [...]
+| *camel.main.dumpRoutes* | If dumping is enabled then Camel will during 
startup dump all loaded routes (incl rests and route templates) represented as 
XML DSL into the log. This is intended for trouble shooting or to assist during 
development. Sensitive information that may be configured in the route 
endpoints could potentially be included in the dump output and is therefore not 
recommended being used for production usage. This requires to have 
camel-xml-jaxb on the classpath to be able [...]
 | *camel.main.durationHitExitCode* | Sets the exit code for the application if 
duration was hit |  | int
 | *camel.main.durationMaxAction* | Controls whether the Camel application 
should shutdown the JVM, or stop all routes, when duration max is triggered. | 
shutdown | String
 | *camel.main.durationMaxIdle{zwsp}Seconds* | To specify for how long time in 
seconds Camel can be idle before automatic terminating the JVM. You can use 
this to run Camel for a short while. |  | int
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 078eb7c..221edc5 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -63,8 +63,8 @@ import org.apache.camel.support.service.BaseService;
 import org.apache.camel.support.startup.LoggingStartupStepRecorder;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.OrderedLocationProperties;
 import org.apache.camel.util.OrderedProperties;
-import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.SensitiveUtils;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.vault.VaultConfiguration;
@@ -92,7 +92,7 @@ public abstract class BaseMainSupport extends BaseService {
     protected final List<MainListener> listeners = new ArrayList<>();
     protected volatile CamelContext camelContext;
     protected MainConfigurationProperties mainConfigurationProperties = new 
MainConfigurationProperties();
-    protected Properties wildcardProperties = new OrderedProperties();
+    protected OrderedLocationProperties wildcardProperties = new 
OrderedLocationProperties();
     protected RoutesCollector routesCollector = new DefaultRoutesCollector();
     protected String propertyPlaceholderLocations;
     protected String defaultPropertyPlaceholderLocation = 
DEFAULT_PROPERTY_PLACEHOLDER_LOCATION;
@@ -377,7 +377,7 @@ public abstract class BaseMainSupport extends BaseService {
 
     protected void autoconfigure(CamelContext camelContext) throws Exception {
         // gathers the properties (key=value) that was auto-configured
-        final Map<String, String> autoConfiguredProperties = new 
LinkedHashMap<>();
+        final OrderedLocationProperties autoConfiguredProperties = new 
OrderedLocationProperties();
 
         // need to eager allow to auto-configure properties component
         if (mainConfigurationProperties.isAutoConfigurationEnabled()) {
@@ -407,13 +407,17 @@ public abstract class BaseMainSupport extends BaseService 
{
         // log summary of configurations
         if (mainConfigurationProperties.isAutoConfigurationLogSummary() && 
!autoConfiguredProperties.isEmpty()) {
             LOG.info("Auto-configuration summary");
-            autoConfiguredProperties.forEach((k, v) -> {
+            for (var entry : autoConfiguredProperties.entrySet()) {
+                String k = entry.getKey().toString();
+                Object v = entry.getValue();
+                String loc = locationSummary(autoConfiguredProperties, k);
+
                 if (SensitiveUtils.containsSensitive(k)) {
-                    LOG.info("    {}=xxxxxx", k);
+                    LOG.info("    {} {}=xxxxxx", loc, k);
                 } else {
-                    LOG.info("    {}={}", k, v);
+                    LOG.info("    {} {}={}", loc, k, v);
                 }
-            });
+            }
         }
 
         // we are now done with the main helper during bootstrap
@@ -425,42 +429,28 @@ public abstract class BaseMainSupport extends BaseService 
{
         // and we want to start jfr recording as early as possible to also 
capture details during bootstrapping Camel
 
         // load properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."),
+                MainHelper::optionKey);
 
         Object value = prop.remove("camel.main.startupRecorder");
-        if (value == null) {
-            value = prop.remove("camel.main.startup-recorder");
-        }
         if (value != null) {
             mainConfigurationProperties.setStartupRecorder(value.toString());
         }
 
         value = prop.remove("camel.main.startupRecorderRecording");
-        if (value == null) {
-            value = prop.remove("camel.main.startup-recorder-recording");
-        }
         if (value != null) {
             
mainConfigurationProperties.setStartupRecorderRecording("true".equalsIgnoreCase(value.toString()));
         }
         value = prop.remove("camel.main.startupRecorderProfile");
-        if (value == null) {
-            value = prop.remove("camel.main.startup-recorder-profile");
-        }
         if (value != null) {
             mainConfigurationProperties.setStartupRecorderProfile(
                     CamelContextHelper.parseText(camelContext, 
value.toString()));
         }
         value = prop.remove("camel.main.startupRecorderDuration");
-        if (value == null) {
-            value = prop.remove("camel.main.startup-recorder-duration");
-        }
         if (value != null) {
             
mainConfigurationProperties.setStartupRecorderDuration(Long.parseLong(value.toString()));
         }
         value = prop.remove("camel.main.startupRecorderMaxDepth");
-        if (value == null) {
-            value = prop.remove("camel.main.startup-recorder-max-depth");
-        }
         if (value != null) {
             
mainConfigurationProperties.setStartupRecorderMaxDepth(Integer.parseInt(value.toString()));
         }
@@ -598,10 +588,11 @@ public abstract class BaseMainSupport extends BaseService 
{
         }
     }
 
-    protected void autoConfigurationFailFast(CamelContext camelContext, 
Map<String, String> autoConfiguredProperties)
+    protected void autoConfigurationFailFast(CamelContext camelContext, 
OrderedLocationProperties autoConfiguredProperties)
             throws Exception {
         // load properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties prop = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
         LOG.debug("Properties from Camel properties component:");
         for (String key : prop.stringPropertyNames()) {
             LOG.debug("    {}={}", key, prop.getProperty(key));
@@ -609,25 +600,21 @@ public abstract class BaseMainSupport extends BaseService 
{
 
         // special for environment-variable-enabled as we need to know this 
early before we set all the other options
         Object envEnabled = 
prop.remove("camel.main.autoConfigurationEnvironmentVariablesEnabled");
-        if (envEnabled == null) {
-            envEnabled = 
prop.remove("camel.main.auto-configuration-environment-variables-enabled");
-            if (envEnabled != null) {
-                
mainConfigurationProperties.setAutoConfigurationEnvironmentVariablesEnabled(
-                        CamelContextHelper.parseBoolean(camelContext, 
envEnabled.toString()));
-                
autoConfiguredProperties.put("camel.main.auto-configuration-environment-variables-enabled",
-                        envEnabled.toString());
-            }
+        if (envEnabled != null) {
+            
mainConfigurationProperties.setAutoConfigurationEnvironmentVariablesEnabled(
+                    CamelContextHelper.parseBoolean(camelContext, 
envEnabled.toString()));
+            String loc = 
prop.getLocation("camel.main.autoConfigurationEnvironmentVariablesEnabled");
+            autoConfiguredProperties.put(loc, 
"camel.main.autoConfigurationEnvironmentVariablesEnabled",
+                    envEnabled.toString());
         }
         // special for system-properties-enabled as we need to know this early 
before we set all the other options
         Object jvmEnabled = 
prop.remove("camel.main.autoConfigurationSystemPropertiesEnabled");
-        if (jvmEnabled == null) {
-            jvmEnabled = 
prop.remove("camel.main.auto-configuration-system-properties-enabled");
-            if (jvmEnabled != null) {
-                
mainConfigurationProperties.setAutoConfigurationSystemPropertiesEnabled(
-                        CamelContextHelper.parseBoolean(camelContext, 
jvmEnabled.toString()));
-                
autoConfiguredProperties.put("camel.main.auto-configuration-system-properties-enabled",
-                        jvmEnabled.toString());
-            }
+        if (jvmEnabled != null) {
+            
mainConfigurationProperties.setAutoConfigurationSystemPropertiesEnabled(
+                    CamelContextHelper.parseBoolean(camelContext, 
jvmEnabled.toString()));
+            String loc = 
prop.getLocation("camel.main.autoConfigurationSystemPropertiesEnabled");
+            autoConfiguredProperties.put(loc, 
"camel.autoConfigurationSystemPropertiesEnabled",
+                    jvmEnabled.toString());
         }
 
         // load properties from ENV (override existing)
@@ -656,68 +643,65 @@ public abstract class BaseMainSupport extends BaseService 
{
         }
 
         // special for fail-fast as we need to know this early before we set 
all the other options
+        String loc = "ENV";
         Object failFast = propENV != null ? 
propENV.remove("camel.main.autoconfigurationfailfast") : null;
         if (propJVM != null) {
             Object val = 
propJVM.remove("camel.main.autoconfigurationfailfast");
             if (val != null) {
+                loc = "SYS";
                 failFast = val;
             }
         }
         if (failFast != null) {
             mainConfigurationProperties
                     
.setAutoConfigurationFailFast(CamelContextHelper.parseBoolean(camelContext, 
failFast.toString()));
-            
autoConfiguredProperties.put("camel.main.auto-configuration-fail-fast", 
failFast.toString());
+            autoConfiguredProperties.put(loc, 
"camel.main.autoConfigurationFailFast", failFast.toString());
         } else {
+            loc = prop.getLocation("camel.main.autoConfigurationFailFast");
             failFast = prop.remove("camel.main.autoConfigurationFailFast");
-            if (failFast == null) {
-                failFast = 
prop.remove("camel.main.auto-configuration-fail-fast");
-            }
             if (failFast != null) {
                 mainConfigurationProperties
                         
.setAutoConfigurationFailFast(CamelContextHelper.parseBoolean(camelContext, 
failFast.toString()));
-                
autoConfiguredProperties.put("camel.main.auto-configuration-fail-fast", 
failFast.toString());
+                autoConfiguredProperties.put(loc, 
"camel.main.autoConfigurationFailFast", failFast.toString());
             }
         }
     }
 
     protected void autoConfigurationRoutesIncludePattern(
-            CamelContext camelContext, Map<String, String> 
autoConfiguredProperties) {
+            CamelContext camelContext, OrderedLocationProperties 
autoConfiguredProperties) {
 
         Object pattern = 
getInitialProperties().getProperty("camel.main.routesIncludePattern");
         if (pattern != null) {
             mainConfigurationProperties
                     
.setRoutesIncludePattern(CamelContextHelper.parseText(camelContext, 
pattern.toString()));
-            autoConfiguredProperties.put("camel.main.routes-include-pattern", 
pattern.toString());
+            autoConfiguredProperties.put("initial", 
"camel.main.routesIncludePattern", pattern.toString());
         }
 
         // load properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties prop = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
         LOG.debug("Properties from Camel properties component:");
         for (String key : prop.stringPropertyNames()) {
             LOG.debug("    {}={}", key, prop.getProperty(key));
         }
 
         // special for environment-variable-enabled as we need to know this 
early before we set all the other options
+        String loc = prop.getLocation("camel.main.routesIncludePattern");
         pattern = prop.remove("camel.main.routesIncludePattern");
-        if (pattern == null) {
-            pattern = prop.remove("camel.main.routes-include-pattern");
-            if (pattern != null) {
-                mainConfigurationProperties.setRoutesIncludePattern(
-                        CamelContextHelper.parseText(camelContext, 
pattern.toString()));
-                
autoConfiguredProperties.put("camel.main.routes-include-pattern",
-                        pattern.toString());
-            }
+        if (pattern != null) {
+            mainConfigurationProperties.setRoutesIncludePattern(
+                    CamelContextHelper.parseText(camelContext, 
pattern.toString()));
+            autoConfiguredProperties.put(loc, 
"camel.main.routesIncludePattern",
+                    pattern.toString());
         }
         // special for system-properties-enabled as we need to know this early 
before we set all the other options
+        loc = prop.getLocation("camel.main.routesIncludePattern");
         Object jvmEnabled = prop.remove("camel.main.routesIncludePattern");
-        if (jvmEnabled == null) {
-            jvmEnabled = prop.remove("camel.main.routes-include-pattern");
-            if (jvmEnabled != null) {
-                mainConfigurationProperties.setRoutesIncludePattern(
-                        CamelContextHelper.parseText(camelContext, 
jvmEnabled.toString()));
-                
autoConfiguredProperties.put("camel.main.routes-include-pattern",
-                        jvmEnabled.toString());
-            }
+        if (jvmEnabled != null) {
+            mainConfigurationProperties.setRoutesIncludePattern(
+                    CamelContextHelper.parseText(camelContext, 
jvmEnabled.toString()));
+            autoConfiguredProperties.put(loc, 
"camel.main.routesIncludePattern",
+                    jvmEnabled.toString());
         }
 
         // load properties from ENV (override existing)
@@ -725,7 +709,7 @@ public abstract class BaseMainSupport extends BaseService {
         if 
(mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
             propENV = helper.loadEnvironmentVariablesAsProperties(new String[] 
{ "camel.main." });
             if (!propENV.isEmpty()) {
-                prop.putAll(propENV);
+                prop.putAll("ENV", propENV);
                 LOG.debug("Properties from OS environment variables:");
                 for (String key : propENV.stringPropertyNames()) {
                     LOG.debug("    {}={}", key, propENV.getProperty(key));
@@ -737,7 +721,7 @@ public abstract class BaseMainSupport extends BaseService {
         if 
(mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
             propJVM = helper.loadJvmSystemPropertiesAsProperties(new String[] 
{ "camel.main." });
             if (!propJVM.isEmpty()) {
-                prop.putAll(propJVM);
+                prop.putAll("SYS", propJVM);
                 LOG.debug("Properties from JVM system properties:");
                 for (String key : propJVM.stringPropertyNames()) {
                     LOG.debug("    {}={}", key, propJVM.getProperty(key));
@@ -746,26 +730,26 @@ public abstract class BaseMainSupport extends BaseService 
{
         }
 
         // special for fail-fast as we need to know this early before we set 
all the other options
+        loc = "ENV";
         pattern = propENV != null ? 
propENV.remove("camel.main.routesincludepattern") : null;
         if (propJVM != null) {
             Object val = propJVM.remove("camel.main.routesincludepattern");
             if (val != null) {
+                loc = "SYS";
                 pattern = val;
             }
         }
         if (pattern != null) {
             mainConfigurationProperties
                     
.setRoutesIncludePattern(CamelContextHelper.parseText(camelContext, 
pattern.toString()));
-            autoConfiguredProperties.put("camel.main.routes-include-pattern", 
pattern.toString());
+            autoConfiguredProperties.put(loc, 
"camel.main.routesIncludePattern", pattern.toString());
         } else {
+            loc = prop.getLocation("camel.main.routesIncludePattern");
             pattern = prop.remove("camel.main.routesIncludePattern");
-            if (pattern == null) {
-                pattern = prop.remove("camel.main.routes-include-pattern");
-            }
             if (pattern != null) {
                 mainConfigurationProperties
                         
.setRoutesIncludePattern(CamelContextHelper.parseText(camelContext, 
pattern.toString()));
-                
autoConfiguredProperties.put("camel.main.routes-include-pattern", 
pattern.toString());
+                autoConfiguredProperties.put(loc, 
"camel.main.routesIncludePattern", pattern.toString());
             }
         }
     }
@@ -775,7 +759,7 @@ public abstract class BaseMainSupport extends BaseService {
      */
     protected void doConfigureCamelContextFromMainConfiguration(
             CamelContext camelContext, MainConfigurationProperties config,
-            Map<String, String> autoConfiguredProperties)
+            OrderedLocationProperties autoConfiguredProperties)
             throws Exception {
 
         if (config.getFileConfigurations() != null) {
@@ -813,13 +797,14 @@ public abstract class BaseMainSupport extends BaseService 
{
         DefaultConfigurationConfigurer.afterConfigure(camelContext);
 
         // now configure context/hystrix/resilience4j/rest with additional 
properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties prop = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
 
         // load properties from ENV (override existing)
         if 
(mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
             Properties propENV = 
helper.loadEnvironmentVariablesAsProperties(new String[] { 
"camel.component.properties." });
             if (!propENV.isEmpty()) {
-                prop.putAll(propENV);
+                prop.putAll("ENV", propENV);
                 LOG.debug("Properties from OS environment variables:");
                 for (String key : propENV.stringPropertyNames()) {
                     LOG.debug("    {}={}", key, propENV.getProperty(key));
@@ -830,7 +815,7 @@ public abstract class BaseMainSupport extends BaseService {
         if 
(mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
             Properties propJVM = 
helper.loadJvmSystemPropertiesAsProperties(new String[] { 
"camel.component.properties." });
             if (!propJVM.isEmpty()) {
-                prop.putAll(propJVM);
+                prop.putAll("SYS", propJVM);
                 LOG.debug("Properties from JVM system properties:");
                 for (String key : propJVM.stringPropertyNames()) {
                     LOG.debug("    {}={}", key, propJVM.getProperty(key));
@@ -838,104 +823,108 @@ public abstract class BaseMainSupport extends 
BaseService {
             }
         }
 
-        Map<String, Object> contextProperties = new LinkedHashMap<>();
-        Map<String, Object> hystrixProperties = new LinkedHashMap<>();
-        Map<String, Object> resilience4jProperties = new LinkedHashMap<>();
-        Map<String, Object> faultToleranceProperties = new LinkedHashMap<>();
-        Map<String, Object> restProperties = new LinkedHashMap<>();
-        Map<String, Object> vaultProperties = new LinkedHashMap<>();
-        Map<String, Object> threadPoolProperties = new LinkedHashMap<>();
-        Map<String, Object> healthProperties = new LinkedHashMap<>();
-        Map<String, Object> lraProperties = new LinkedHashMap<>();
-        Map<String, Object> routeTemplateProperties = new LinkedHashMap<>();
-        Map<String, Object> beansProperties = new LinkedHashMap<>();
-        Map<String, Object> devConsoleProperties = new LinkedHashMap<>();
-        Map<String, String> globalOptions = new LinkedHashMap<>();
+        OrderedLocationProperties contextProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties hystrixProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties resilience4jProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties faultToleranceProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties restProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties vaultProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties threadPoolProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties healthProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties lraProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties routeTemplateProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties beansProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties devConsoleProperties = new 
OrderedLocationProperties();
+        OrderedLocationProperties globalOptions = new 
OrderedLocationProperties();
         for (String key : prop.stringPropertyNames()) {
+            String loc = prop.getLocation(key);
             if (key.startsWith("camel.context.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(14);
                 validateOptionAndValue(key, option, value);
-                contextProperties.put(optionKey(option), value);
+                contextProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.hystrix.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(14);
                 validateOptionAndValue(key, option, value);
-                hystrixProperties.put(optionKey(option), value);
+                hystrixProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.resilience4j.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(19);
                 validateOptionAndValue(key, option, value);
-                resilience4jProperties.put(optionKey(option), value);
+                resilience4jProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.faulttolerance.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(21);
                 validateOptionAndValue(key, option, value);
-                faultToleranceProperties.put(optionKey(option), value);
+                faultToleranceProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.rest.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(11);
                 validateOptionAndValue(key, option, value);
-                restProperties.put(optionKey(option), value);
+                restProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.vault.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(12);
                 validateOptionAndValue(key, option, value);
-                vaultProperties.put(optionKey(option), value);
+                vaultProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.threadpool.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(17);
                 validateOptionAndValue(key, option, value);
-                threadPoolProperties.put(optionKey(option), value);
+                threadPoolProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.health.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(13);
                 validateOptionAndValue(key, option, value);
-                healthProperties.put(optionKey(option), value);
+                healthProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.lra.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(10);
                 validateOptionAndValue(key, option, value);
-                lraProperties.put(optionKey(option), value);
-            } else if (key.startsWith("camel.route-template")) {
+                lraProperties.put(loc, optionKey(option), value);
+            } else if (key.startsWith("camel.routeTemplate")) {
                 // grab the value
                 String value = prop.getProperty(key);
-                String option = key.substring(20);
+                String option = key.substring(19);
                 validateOptionAndValue(key, option, value);
-                routeTemplateProperties.put(optionKey(option), value);
-            } else if (key.startsWith("camel.dev-console.")) {
+                routeTemplateProperties.put(loc, optionKey(option), value);
+            } else if (key.startsWith("camel.devConsole.")) {
                 // grab the value
                 String value = prop.getProperty(key);
-                String option = key.substring(18);
+                String option = key.substring(17);
                 validateOptionAndValue(key, option, value);
-                devConsoleProperties.put(optionKey(option), value);
+                devConsoleProperties.put(loc, optionKey(option), value);
             } else if (key.startsWith("camel.beans.")) {
                 // grab the value
                 String value = prop.getProperty(key);
                 String option = key.substring(12);
                 validateOptionAndValue(key, option, value);
-                beansProperties.put(optionKey(option), value);
-            } else if (key.startsWith("camel.global-options.")) {
+                beansProperties.put(loc, optionKey(option), value);
+            } else if (key.startsWith("camel.globalOptions.")) {
                 // grab the value
                 String value = prop.getProperty(key);
-                String option = key.substring(21);
+                String option = key.substring(20);
                 validateOptionAndValue(key, option, value);
-                globalOptions.put(optionKey(option), value);
+                globalOptions.put(loc, optionKey(option), value);
             }
         }
 
         // global options first
         if (!globalOptions.isEmpty()) {
-            mainConfigurationProperties.setGlobalOptions(globalOptions);
+            for (var name : globalOptions.stringPropertyNames()) {
+                Object value = globalOptions.getProperty(name);
+                mainConfigurationProperties.addGlobalOption(name, value);
+            }
         }
         // create beans first as they may be used later
         if (!beansProperties.isEmpty()) {
@@ -1059,30 +1048,32 @@ public abstract class BaseMainSupport extends 
BaseService {
     }
 
     private void setRouteTemplateProperties(
-            CamelContext camelContext, Map<String, Object> 
routeTemplateProperties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, OrderedLocationProperties 
routeTemplateProperties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         // store the route template parameters as a source and register it on 
the camel context
         PropertiesRouteTemplateParametersSource source = new 
PropertiesRouteTemplateParametersSource();
-        for (Map.Entry<String, Object> entry : 
routeTemplateProperties.entrySet()) {
-            String id = StringHelper.between(entry.getKey(), "[", "]");
-            String key = StringHelper.after(entry.getKey(), "].");
+        for (Map.Entry<Object, Object> entry : 
routeTemplateProperties.entrySet()) {
+            String key = entry.getKey().toString();
+            String id = StringHelper.between(key, "[", "]");
+            key = StringHelper.after(key, "].");
             source.addParameter(id, key, entry.getValue());
         }
         
camelContext.getRegistry().bind("CamelMainRouteTemplateParametersSource", 
RouteTemplateParameterSource.class, source);
 
         // lets sort by keys
-        Map<String, Object> sorted = new TreeMap<>(routeTemplateProperties);
+        Map<String, Object> sorted = new 
TreeMap<>(routeTemplateProperties.asMap());
         sorted.forEach((k, v) -> {
-            autoConfiguredProperties.put("camel.route-template" + k, 
v.toString());
+            String loc = routeTemplateProperties.getLocation(k);
+            autoConfiguredProperties.put(loc, "camel.routeTemplate" + k, 
v.toString());
         });
         routeTemplateProperties.clear();
     }
 
     private void setHealthCheckProperties(
-            CamelContext camelContext, Map<String, Object> 
healthCheckProperties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, OrderedLocationProperties 
healthCheckProperties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         HealthConfigurationProperties health = 
mainConfigurationProperties.health();
@@ -1156,13 +1147,14 @@ public abstract class BaseMainSupport extends 
BaseService {
     }
 
     private void setLraCheckProperties(
-            CamelContext camelContext, Map<String, Object> lraProperties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, OrderedLocationProperties lraProperties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         Object obj = lraProperties.remove("enabled");
         if (obj != null) {
-            autoConfiguredProperties.put("camel.lra.enabled", obj.toString());
+            String loc = lraProperties.getLocation("enabled");
+            autoConfiguredProperties.put(loc, "camel.lra.enabled", 
obj.toString());
         }
         boolean enabled = obj != null ? 
CamelContextHelper.parseBoolean(camelContext, obj.toString()) : true;
         if (enabled) {
@@ -1172,12 +1164,12 @@ public abstract class BaseMainSupport extends 
BaseService {
     }
 
     private void setDevConsoleProperties(
-            CamelContext camelContext, Map<String, Object> properties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, OrderedLocationProperties properties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         // make defensive copy as we mutate the map
-        Set<String> keys = new LinkedHashSet<>(properties.keySet());
+        Set<String> keys = new LinkedHashSet(properties.keySet());
         // set properties per console
         for (String key : keys) {
             String name = StringHelper.before(key, ".");
@@ -1187,15 +1179,15 @@ public abstract class BaseMainSupport extends 
BaseService {
                         "Cannot resolve DevConsole with id: " + name);
             }
             // configure all the properties on the console at once (to ensure 
they are configured in right order)
-            Map<String, Object> config = 
PropertiesHelper.extractProperties(properties, name + ".");
-            setPropertiesOnTarget(camelContext, console, config, 
"camel.dev-console." + name + ".", failIfNotSet, true,
+            OrderedLocationProperties config = 
MainHelper.extractProperties(properties, name + ".");
+            setPropertiesOnTarget(camelContext, console, config, 
"camel.devConsole." + name + ".", failIfNotSet, true,
                     autoConfiguredProperties);
         }
     }
 
     private void setVaultProperties(
-            CamelContext camelContext, Map<String, Object> properties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, OrderedLocationProperties properties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         if (mainConfigurationProperties.hasVaultConfiguration()) {
@@ -1204,7 +1196,7 @@ public abstract class BaseMainSupport extends BaseService 
{
         VaultConfiguration target = camelContext.getVaultConfiguration();
 
         // make defensive copy as we mutate the map
-        Set<String> keys = new LinkedHashSet<>(properties.keySet());
+        Set<String> keys = new LinkedHashSet(properties.keySet());
         // set properties per different vault component
         for (String key : keys) {
             String name = StringHelper.before(key, ".");
@@ -1215,23 +1207,24 @@ public abstract class BaseMainSupport extends 
BaseService {
                 target = target.gcp();
             }
             // configure all the properties on the vault at once (to ensure 
they are configured in right order)
-            Map<String, Object> config = 
PropertiesHelper.extractProperties(properties, name + ".");
+            OrderedLocationProperties config = 
MainHelper.extractProperties(properties, name + ".");
             setPropertiesOnTarget(camelContext, target, config, "camel.vault." 
+ name + ".", failIfNotSet, true,
                     autoConfiguredProperties);
         }
     }
 
     private void bindBeansToRegistry(
-            CamelContext camelContext, Map<String, Object> properties,
+            CamelContext camelContext, OrderedLocationProperties properties,
             String optionPrefix, boolean failIfNotSet, boolean logSummary, 
boolean ignoreCase,
-            Map<String, String> autoConfiguredProperties)
+            OrderedLocationProperties autoConfiguredProperties)
             throws Exception {
 
         // make defensive copy as we mutate the map
-        Set<String> keys = new LinkedHashSet<>(properties.keySet());
+        Set<String> keys = new LinkedHashSet(properties.keySet());
         // find names of beans
         final Set<String> beans
-                = properties.keySet().stream().map(k -> StringHelper.before(k, 
".", k)).collect(Collectors.toSet());
+                = properties.keySet().stream().map(k -> 
StringHelper.before(k.toString(), ".", k.toString()))
+                        .collect(Collectors.toSet());
         // create beans first
         for (String key : keys) {
             if (key.indexOf('.') == -1) {
@@ -1259,33 +1252,35 @@ public abstract class BaseMainSupport extends 
BaseService {
                         "Cannot resolve bean with name " + name);
             }
             // configure all the properties on the bean at once (to ensure 
they are configured in right order)
-            Map<String, Object> config = 
PropertiesHelper.extractProperties(properties, name + ".");
+            OrderedLocationProperties config = 
MainHelper.extractProperties(properties, name + ".");
             setPropertiesOnTarget(camelContext, bean, config, optionPrefix + 
name + ".", failIfNotSet, ignoreCase,
                     autoConfiguredProperties);
         }
     }
 
-    protected void autoConfigurationPropertiesComponent(CamelContext 
camelContext, Map<String, String> autoConfiguredProperties)
+    protected void autoConfigurationPropertiesComponent(
+            CamelContext camelContext, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
         // load properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties prop = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
 
         // load properties from ENV (override existing)
         if 
(mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
             Properties propENV = 
helper.loadEnvironmentVariablesAsProperties(new String[] { 
"camel.component.properties." });
             if (!propENV.isEmpty()) {
-                prop.putAll(propENV);
+                prop.putAll("ENV", propENV);
             }
         }
         // load properties from JVM (override existing)
         if 
(mainConfigurationProperties.isAutoConfigurationSystemPropertiesEnabled()) {
             Properties propJVM = 
helper.loadJvmSystemPropertiesAsProperties(new String[] { 
"camel.component.properties." });
             if (!propJVM.isEmpty()) {
-                prop.putAll(propJVM);
+                prop.putAll("SYS", propJVM);
             }
         }
 
-        Map<String, Object> properties = new LinkedHashMap<>();
+        OrderedLocationProperties properties = new OrderedLocationProperties();
 
         for (String key : prop.stringPropertyNames()) {
             if (key.startsWith("camel.component.properties.")) {
@@ -1293,7 +1288,8 @@ public abstract class BaseMainSupport extends BaseService 
{
                 String option = dot == -1 ? "" : key.substring(dot + 1);
                 String value = prop.getProperty(key, "");
                 validateOptionAndValue(key, option, value);
-                properties.put(optionKey(option), value);
+                String loc = prop.getLocation(key);
+                properties.put(loc, optionKey(option), value);
             }
         }
 
@@ -1314,10 +1310,11 @@ public abstract class BaseMainSupport extends 
BaseService {
     }
 
     protected void autoConfigurationMainConfiguration(
-            CamelContext camelContext, MainConfigurationProperties config, 
Map<String, String> autoConfiguredProperties)
+            CamelContext camelContext, MainConfigurationProperties config, 
OrderedLocationProperties autoConfiguredProperties)
             throws Exception {
         // load properties
-        Properties prop = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties prop = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
 
         // load properties from ENV (override existing)
         if 
(mainConfigurationProperties.isAutoConfigurationEnvironmentVariablesEnabled()) {
@@ -1328,7 +1325,7 @@ public abstract class BaseMainSupport extends BaseService 
{
             propENV.remove(OVERRIDE_PROPERTIES_LOCATION.replace('-', '.'));
             propENV.remove(PROPERTY_PLACEHOLDER_LOCATION.replace('-', '.'));
             if (!propENV.isEmpty()) {
-                prop.putAll(propENV);
+                prop.putAll("ENV", propENV);
             }
         }
         // load properties from JVM (override existing)
@@ -1342,11 +1339,11 @@ public abstract class BaseMainSupport extends 
BaseService {
             propJVM.remove(PROPERTY_PLACEHOLDER_LOCATION);
             
propJVM.remove(StringHelper.dashToCamelCase(PROPERTY_PLACEHOLDER_LOCATION));
             if (!propJVM.isEmpty()) {
-                prop.putAll(propJVM);
+                prop.putAll("SYS", propJVM);
             }
         }
 
-        Map<String, Object> properties = new LinkedHashMap<>();
+        OrderedLocationProperties properties = new OrderedLocationProperties();
 
         for (String key : prop.stringPropertyNames()) {
             if (key.startsWith("camel.main.")) {
@@ -1354,7 +1351,8 @@ public abstract class BaseMainSupport extends BaseService 
{
                 String value = prop.getProperty(key);
                 String option = key.substring(11);
                 validateOptionAndValue(key, option, value);
-                properties.put(optionKey(option), value);
+                String loc = prop.getLocation(key);
+                properties.put(loc, optionKey(option), value);
             }
         }
 
@@ -1372,12 +1370,14 @@ public abstract class BaseMainSupport extends 
BaseService {
         }
     }
 
-    protected void autoConfigurationFromProperties(CamelContext camelContext, 
Map<String, String> autoConfiguredProperties)
+    protected void autoConfigurationFromProperties(
+            CamelContext camelContext, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
-        Properties prop = new OrderedProperties();
+        OrderedLocationProperties prop = new OrderedLocationProperties();
 
         // load properties from properties component (override existing)
-        Properties propPC = 
camelContext.getPropertiesComponent().loadProperties(name -> 
name.startsWith("camel."));
+        OrderedLocationProperties propPC = (OrderedLocationProperties) 
camelContext.getPropertiesComponent()
+                .loadProperties(name -> name.startsWith("camel."), 
MainHelper::optionKey);
         prop.putAll(propPC);
 
         // load properties from ENV (override existing)
@@ -1401,7 +1401,7 @@ public abstract class BaseMainSupport extends BaseService 
{
             }
 
             if (!propENV.isEmpty()) {
-                prop.putAll(propENV);
+                prop.putAll("ENV", propENV);
             }
         }
         // load properties from JVM (override existing)
@@ -1409,16 +1409,17 @@ public abstract class BaseMainSupport extends 
BaseService {
             Properties propJVM = 
MainHelper.loadJvmSystemPropertiesAsProperties(
                     new String[] { "camel.component.", "camel.dataformat.", 
"camel.language." });
             if (!propJVM.isEmpty()) {
-                prop.putAll(propJVM);
+                prop.putAll("SYS", propJVM);
             }
         }
 
-        Map<PropertyOptionKey, Map<String, Object>> properties = new 
LinkedHashMap<>();
+        Map<PropertyOptionKey, OrderedLocationProperties> properties = new 
LinkedHashMap<>();
 
         // filter out wildcard properties
         for (String key : prop.stringPropertyNames()) {
             if (key.contains("*")) {
-                wildcardProperties.put(key, prop.getProperty(key));
+                String loc = prop.getLocation(key);
+                wildcardProperties.put(loc, key, prop.getProperty(key));
             }
         }
         // and remove wildcards
@@ -1467,7 +1468,7 @@ public abstract class BaseMainSupport extends BaseService 
{
                     total);
         }
 
-        for (Map.Entry<PropertyOptionKey, Map<String, Object>> entry : 
properties.entrySet()) {
+        for (Map.Entry<PropertyOptionKey, OrderedLocationProperties> entry : 
properties.entrySet()) {
             setPropertiesOnTarget(
                     camelContext,
                     entry.getKey().getInstance(),
@@ -1480,9 +1481,9 @@ public abstract class BaseMainSupport extends BaseService 
{
 
         // log which options was not set
         if (!properties.isEmpty()) {
-            for (Map.Entry<PropertyOptionKey, Map<String, Object>> entry : 
properties.entrySet()) {
+            for (Map.Entry<PropertyOptionKey, OrderedLocationProperties> entry 
: properties.entrySet()) {
                 PropertyOptionKey pok = entry.getKey();
-                Map<String, Object> values = entry.getValue();
+                OrderedLocationProperties values = entry.getValue();
                 values.forEach((k, v) -> {
                     String stringValue = v != null ? v.toString() : null;
                     LOG.warn("Property ({}={}) not auto-configured with name: 
{} on bean: {} with value: {}",
@@ -1513,8 +1514,8 @@ public abstract class BaseMainSupport extends BaseService 
{
     }
 
     protected void doAutowireWildcardProperties(String name, Component 
component) {
-        Map<PropertyOptionKey, Map<String, Object>> properties = new 
LinkedHashMap<>();
-        Map<String, String> autoConfiguredProperties = new LinkedHashMap<>();
+        Map<PropertyOptionKey, OrderedLocationProperties> properties = new 
LinkedHashMap<>();
+        OrderedLocationProperties autoConfiguredProperties = new 
OrderedLocationProperties();
         String match = ("camel.component." + name).toLowerCase(Locale.ENGLISH);
 
         for (String key : wildcardProperties.stringPropertyNames()) {
@@ -1526,7 +1527,7 @@ public abstract class BaseMainSupport extends BaseService 
{
         }
 
         try {
-            for (Map.Entry<PropertyOptionKey, Map<String, Object>> entry : 
properties.entrySet()) {
+            for (Map.Entry<PropertyOptionKey, OrderedLocationProperties> entry 
: properties.entrySet()) {
                 setPropertiesOnTarget(
                         camelContext,
                         entry.getKey().getInstance(),
@@ -1539,13 +1540,17 @@ public abstract class BaseMainSupport extends 
BaseService {
             // log summary of configurations
             if (mainConfigurationProperties.isAutoConfigurationLogSummary() && 
!autoConfiguredProperties.isEmpty()) {
                 LOG.info("Auto-configuration component {} summary", name);
-                autoConfiguredProperties.forEach((k, v) -> {
+                for (var entry : autoConfiguredProperties.entrySet()) {
+                    String k = entry.getKey().toString();
+                    Object v = entry.getValue();
+                    String loc = locationSummary(autoConfiguredProperties, k);
+
                     if (SensitiveUtils.containsSensitive(k)) {
-                        LOG.info("    {}=xxxxxx", k);
+                        LOG.info("    {} {}=xxxxxx", loc, k);
                     } else {
-                        LOG.info("    {}={}", k, v);
+                        LOG.info("    {} {}={}", loc, k, v);
                     }
-                });
+                }
             }
         } catch (Exception e) {
             throw RuntimeCamelException.wrapRuntimeException(e);
@@ -1567,4 +1572,30 @@ public abstract class BaseMainSupport extends 
BaseService {
         return answer;
     }
 
+    private static String locationSummary(OrderedLocationProperties 
autoConfiguredProperties, String key) {
+        String loc = autoConfiguredProperties.getLocation(key);
+        if (loc == null) {
+            loc = "";
+        }
+        // remove scheme to make it shorter
+        if (loc.contains(":")) {
+            loc = StringHelper.after(loc, ":");
+        }
+        if (loc.length() > 28) {
+            int pos = loc.length() - 28;
+            loc = loc.substring(pos);
+        }
+        // let us have human friendly locations
+        if ("initial".equals(loc) || "override".equals(loc)) {
+            loc = "camel-main";
+        } else if ("SYS".equals(loc)) {
+            loc = "JVM System Property";
+        } else if ("ENV".equals(loc)) {
+            loc = "OS Environment Variable";
+        }
+        loc = "[" + loc + "]";
+        loc = String.format("%-30s", loc);
+        return loc;
+    }
+
 }
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index 2b844fe..d416420 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -1212,7 +1212,7 @@ public abstract class DefaultConfigurationProperties<T> {
      * represented as XML DSL into the log. This is intended for trouble 
shooting or to assist during development.
      *
      * Sensitive information that may be configured in the route endpoints 
could potentially be included in the dump
-     * output and is therefore not recommended to be used for production usage.
+     * output and is therefore not recommended being used for production usage.
      *
      * This requires to have camel-xml-jaxb on the classpath to be able to 
dump the routes as XML.
      */
@@ -1234,6 +1234,19 @@ public abstract class DefaultConfigurationProperties<T> {
         this.globalOptions = globalOptions;
     }
 
+    /**
+     * Adds a global options that can be referenced in the camel context
+     * <p/>
+     * <b>Important:</b> This has nothing to do with property placeholders, 
and is just a plain set of key/value pairs
+     * which are used to configure global options on CamelContext, such as a 
maximum debug logging length etc.
+     */
+    public void addGlobalOption(String key, Object value) {
+        if (this.globalOptions == null) {
+            this.globalOptions = new HashMap<>();
+        }
+        this.globalOptions.put(key, value.toString());
+    }
+
     @Deprecated
     public LoggingLevel getRouteControllerLoggingLevel() {
         return routeControllerLoggingLevel;
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java 
b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
index 05b100d..5b073d9 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java
@@ -23,7 +23,6 @@ import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Optional;
@@ -41,6 +40,7 @@ import org.apache.camel.support.PropertyBindingSupport;
 import org.apache.camel.support.service.ServiceHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.OrderedLocationProperties;
 import org.apache.camel.util.OrderedProperties;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.TimeUtils;
@@ -280,9 +280,9 @@ public final class MainHelper {
     }
 
     public static boolean setPropertiesOnTarget(
-            CamelContext context, Object target, Map<String, Object> 
properties,
+            CamelContext context, Object target, OrderedLocationProperties 
properties,
             String optionPrefix, boolean failIfNotSet, boolean ignoreCase,
-            Map<String, String> autoConfiguredProperties) {
+            OrderedLocationProperties autoConfiguredProperties) {
 
         ObjectHelper.notNull(context, "context");
         ObjectHelper.notNull(target, "target");
@@ -305,16 +305,17 @@ public final class MainHelper {
 
         try {
             // keep a reference of the original keys
-            Map<String, Object> backup = new LinkedHashMap<>(properties);
+            OrderedLocationProperties backup = new OrderedLocationProperties();
+            backup.putAll(properties);
 
             rc = PropertyBindingSupport.build()
                     .withMandatory(failIfNotSet)
                     .withRemoveParameters(true)
                     .withConfigurer(configurer)
                     .withIgnoreCase(ignoreCase)
-                    .bind(context, target, properties);
+                    .bind(context, target, properties.asMap());
 
-            for (Map.Entry<String, Object> entry : backup.entrySet()) {
+            for (Map.Entry<Object, Object> entry : backup.entrySet()) {
                 if (entry.getValue() != null && 
!properties.containsKey(entry.getKey())) {
                     String prefix = optionPrefix;
                     if (prefix != null && !prefix.endsWith(".")) {
@@ -322,7 +323,9 @@ public final class MainHelper {
                     }
 
                     LOG.debug("Configured property: {}{}={} on bean: {}", 
prefix, entry.getKey(), entry.getValue(), target);
-                    autoConfiguredProperties.put(prefix + entry.getKey(), 
entry.getValue().toString());
+                    String loc = backup.getLocation(entry.getKey());
+                    String key = prefix + entry.getKey();
+                    autoConfiguredProperties.put(loc, key, entry.getValue());
                 }
             }
         } catch (PropertyBindingException e) {
@@ -353,7 +356,8 @@ public final class MainHelper {
     }
 
     public static void computeProperties(
-            String keyPrefix, String key, Properties prop, 
Map<PropertyOptionKey, Map<String, Object>> properties,
+            String keyPrefix, String key, OrderedLocationProperties prop,
+            Map<PropertyOptionKey, OrderedLocationProperties> properties,
             Function<String, Iterable<Object>> supplier) {
         if (key.startsWith(keyPrefix)) {
             // grab name
@@ -398,10 +402,11 @@ public final class MainHelper {
             Iterable<Object> targets = supplier.apply(name);
             for (Object target : targets) {
                 PropertyOptionKey pok = new PropertyOptionKey(target, prefix);
-                Map<String, Object> values = properties.computeIfAbsent(pok, k 
-> new LinkedHashMap<>());
+                OrderedLocationProperties values = 
properties.computeIfAbsent(pok, k -> new OrderedLocationProperties());
+                String loc = prop.getLocation(key);
 
                 // we ignore case for property keys (so we should store them 
in canonical style
-                values.put(optionKey(option), value);
+                values.put(loc, optionKey(option), value);
             }
         }
     }
@@ -487,4 +492,26 @@ public final class MainHelper {
         return version;
     }
 
+    public static OrderedLocationProperties 
extractProperties(OrderedLocationProperties properties, String optionPrefix) {
+        if (properties == null) {
+            return new OrderedLocationProperties();
+        }
+        OrderedLocationProperties rc = new OrderedLocationProperties();
+
+        Set<Object> toRemove = new HashSet<>();
+        for (var entry : properties.entrySet()) {
+            String key = entry.getKey().toString();
+            String loc = properties.getLocation(key);
+            if (key.startsWith(optionPrefix)) {
+                Object value = properties.get(key);
+                key = key.substring(optionPrefix.length());
+                rc.put(loc, key, value);
+                toRemove.add(entry.getKey());
+            }
+        }
+        toRemove.forEach(properties::remove);
+
+        return rc;
+    }
+
 }
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupportModelConfigurer.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupportModelConfigurer.java
index 0c5ce12..e5c1549 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupportModelConfigurer.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupportModelConfigurer.java
@@ -26,6 +26,7 @@ import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.ModelCamelContext;
 import org.apache.camel.model.Resilience4jConfigurationDefinition;
 import org.apache.camel.spi.ThreadPoolProfile;
+import org.apache.camel.util.OrderedLocationProperties;
 import org.apache.camel.util.PropertiesHelper;
 import org.apache.camel.util.StringHelper;
 import org.slf4j.Logger;
@@ -46,10 +47,10 @@ public final class MainSupportModelConfigurer {
     static void configureModelCamelContext(
             CamelContext camelContext,
             MainConfigurationProperties mainConfigurationProperties,
-            Map<String, String> autoConfiguredProperties,
-            Map<String, Object> hystrixProperties,
-            Map<String, Object> resilience4jProperties,
-            Map<String, Object> faultToleranceProperties)
+            OrderedLocationProperties autoConfiguredProperties,
+            OrderedLocationProperties hystrixProperties,
+            OrderedLocationProperties resilience4jProperties,
+            OrderedLocationProperties faultToleranceProperties)
             throws Exception {
 
         ModelCamelContext model = camelContext.adapt(ModelCamelContext.class);
@@ -101,14 +102,14 @@ public final class MainSupportModelConfigurer {
     static void setThreadPoolProperties(
             CamelContext camelContext,
             MainConfigurationProperties mainConfigurationProperties,
-            Map<String, Object> threadPoolProperties,
-            boolean failIfNotSet, Map<String, String> autoConfiguredProperties)
+            OrderedLocationProperties threadPoolProperties,
+            boolean failIfNotSet, OrderedLocationProperties 
autoConfiguredProperties)
             throws Exception {
 
         ThreadPoolConfigurationProperties tp = 
mainConfigurationProperties.threadPool();
 
         // extract all config to know their parent ids so we can set the 
values afterwards
-        Map<String, Object> hcConfig = 
PropertiesHelper.extractProperties(threadPoolProperties, "config", false);
+        Map<String, Object> hcConfig = 
PropertiesHelper.extractProperties(threadPoolProperties.asMap(), "config", 
false);
         Map<String, ThreadPoolProfileConfigurationProperties> tpConfigs = new 
HashMap<>();
         // build set of configuration objects
         for (Map.Entry<String, Object> entry : hcConfig.entrySet()) {
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java 
b/core/camel-util/src/main/java/org/apache/camel/util/BaseOrderedProperties.java
similarity index 81%
copy from 
core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java
copy to 
core/camel-util/src/main/java/org/apache/camel/util/BaseOrderedProperties.java
index 72fd937..7ad820c 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java
+++ 
b/core/camel-util/src/main/java/org/apache/camel/util/BaseOrderedProperties.java
@@ -27,17 +27,14 @@ import java.util.Set;
 import java.util.Vector;
 
 /**
- * This class is an ordered {@link Properties} where the key/values are stored 
in the order they are added or loaded.
- * <p/>
- * Note: This implementation is only intended as implementation detail for the 
Camel properties component, and has only
- * been designed to provide the needed functionality. The complex logic for 
loading properties has been kept from the
- * JDK {@link Properties} class.
+ * Base class for ordered properties implementations.
  */
-public final class OrderedProperties extends Properties {
+abstract class BaseOrderedProperties extends Properties {
 
-    private final Map<String, String> map = new LinkedHashMap<>();
+    private final Map<String, Object> map = new LinkedHashMap<>();
 
-    public OrderedProperties() {
+    public Map<String, Object> asMap() {
+        return map;
     }
 
     @Override
@@ -74,12 +71,12 @@ public final class OrderedProperties extends Properties {
 
     @Override
     public String getProperty(String key) {
-        return map.get(key);
+        return (String) map.get(key);
     }
 
     @Override
     public String getProperty(String key, String defaultValue) {
-        return map.getOrDefault(key, defaultValue);
+        return (String) map.getOrDefault(key, defaultValue);
     }
 
     @Override
@@ -118,4 +115,5 @@ public final class OrderedProperties extends Properties {
     public synchronized String toString() {
         return map.toString();
     }
+
 }
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/OrderedLocationProperties.java
 
b/core/camel-util/src/main/java/org/apache/camel/util/OrderedLocationProperties.java
new file mode 100644
index 0000000..60c6576
--- /dev/null
+++ 
b/core/camel-util/src/main/java/org/apache/camel/util/OrderedLocationProperties.java
@@ -0,0 +1,73 @@
+/*
+ * 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.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * An {@link OrderedProperties} that also keeps track from which location the 
properties are sourced from.
+ *
+ * This can be used to track all the various sources for configuration that a 
Camel application uses (properties file,
+ * ENV variables, hardcoded in java, spring-boot, quarkus, camel-k modeline, 
camel-yaml-dsl etc.
+ *
+ * <b>Important:</b> Use the put method that takes location as argument to 
store location information.
+ */
+public final class OrderedLocationProperties extends BaseOrderedProperties {
+
+    private final Map<Object, String> locations = new HashMap<>();
+
+    public void put(String location, Object key, Object value) {
+        locations.put(key, location);
+        put(key, value);
+    }
+
+    public void putAll(OrderedLocationProperties other) {
+        for (var entry : other.entrySet()) {
+            put(other.getLocation(entry.getKey()), entry.getKey(), 
entry.getValue());
+        }
+    }
+
+    public void putAll(String location, Map<Object, Object> map) {
+        for (var entry : map.entrySet()) {
+            put(location, entry.getKey(), entry.getValue());
+        }
+    }
+
+    public void putAll(String location, Properties properties) {
+        for (var entry : properties.entrySet()) {
+            put(location, entry.getKey(), entry.getValue());
+        }
+    }
+
+    public String getLocation(Object key) {
+        return locations.get(key);
+    }
+
+    @Override
+    public synchronized void clear() {
+        locations.clear();
+        super.clear();
+    }
+
+    @Override
+    public synchronized Object remove(Object key) {
+        locations.remove(key);
+        return super.remove(key);
+    }
+}
diff --git 
a/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java 
b/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java
index 72fd937..3ccc097 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/OrderedProperties.java
@@ -16,15 +16,7 @@
  */
 package org.apache.camel.util;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
-import java.util.Vector;
 
 /**
  * This class is an ordered {@link Properties} where the key/values are stored 
in the order they are added or loaded.
@@ -33,89 +25,6 @@ import java.util.Vector;
  * been designed to provide the needed functionality. The complex logic for 
loading properties has been kept from the
  * JDK {@link Properties} class.
  */
-public final class OrderedProperties extends Properties {
+public final class OrderedProperties extends BaseOrderedProperties {
 
-    private final Map<String, String> map = new LinkedHashMap<>();
-
-    public OrderedProperties() {
-    }
-
-    @Override
-    public synchronized Object put(Object key, Object value) {
-        return map.put(key.toString(), value.toString());
-    }
-
-    @Override
-    public synchronized void putAll(Map<?, ?> t) {
-        for (Map.Entry<?, ?> entry : t.entrySet()) {
-            put(entry.getKey(), entry.getValue());
-        }
-    }
-
-    @Override
-    public synchronized Object get(Object key) {
-        return map.get(key);
-    }
-
-    @Override
-    public synchronized boolean isEmpty() {
-        return map.isEmpty();
-    }
-
-    @Override
-    public synchronized Object remove(Object key) {
-        return map.remove(key);
-    }
-
-    @Override
-    public synchronized void clear() {
-        map.clear();
-    }
-
-    @Override
-    public String getProperty(String key) {
-        return map.get(key);
-    }
-
-    @Override
-    public String getProperty(String key, String defaultValue) {
-        return map.getOrDefault(key, defaultValue);
-    }
-
-    @Override
-    public synchronized Enumeration<Object> keys() {
-        return new Vector<Object>(map.keySet()).elements();
-    }
-
-    @Override
-    public Set<Object> keySet() {
-        return new LinkedHashSet<>(map.keySet());
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Set<Map.Entry<Object, Object>> entrySet() {
-        Set entrySet = map.entrySet();
-        return entrySet;
-    }
-
-    @Override
-    public synchronized int size() {
-        return map.size();
-    }
-
-    @Override
-    public Set<String> stringPropertyNames() {
-        return map.keySet();
-    }
-
-    @Override
-    public Collection<Object> values() {
-        return new ArrayList<>(map.values());
-    }
-
-    @Override
-    public synchronized String toString() {
-        return map.toString();
-    }
 }
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/DependencyTrait.java
 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/DependencyTrait.java
index 8d84d60..637215b 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/DependencyTrait.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/DependencyTrait.java
@@ -19,6 +19,7 @@ package org.apache.camel.dsl.modeline;
 import org.apache.camel.CamelContext;
 import org.apache.camel.spi.CamelContextCustomizer;
 import org.apache.camel.spi.DependencyStrategy;
+import org.apache.camel.spi.Resource;
 
 public class DependencyTrait implements Trait {
 
@@ -28,7 +29,7 @@ public class DependencyTrait implements Trait {
     }
 
     @Override
-    public CamelContextCustomizer parseTrait(String trait) {
+    public CamelContextCustomizer parseTrait(Resource resource, String trait) {
         return new CamelContextCustomizer() {
             @Override
             public void configure(CamelContext camelContext) {
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/EnvTrait.java
 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/EnvTrait.java
index a8ac66b..cf7645d 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/EnvTrait.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/EnvTrait.java
@@ -18,6 +18,7 @@ package org.apache.camel.dsl.modeline;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.spi.Resource;
 import org.apache.camel.util.StringHelper;
 
 public class EnvTrait implements Trait {
@@ -28,7 +29,7 @@ public class EnvTrait implements Trait {
     }
 
     @Override
-    public CamelContextCustomizer parseTrait(String trait) {
+    public CamelContextCustomizer parseTrait(Resource resource, String trait) {
         String key = StringHelper.before(trait, "=").trim();
         String value = StringHelper.after(trait, "=").trim();
         return new CamelContextCustomizer() {
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/ModelineParser.java
 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/ModelineParser.java
index cd1b8d7..3345400 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/ModelineParser.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/ModelineParser.java
@@ -59,7 +59,7 @@ public class ModelineParser {
         try (LineNumberReader reader = new 
LineNumberReader(resource.getReader())) {
             String line = reader.readLine();
             while (line != null) {
-                List<CamelContextCustomizer> list = parse(line);
+                List<CamelContextCustomizer> list = parse(resource, line);
                 answer.addAll(list);
                 line = reader.readLine();
             }
@@ -68,7 +68,7 @@ public class ModelineParser {
         return answer;
     }
 
-    protected List<CamelContextCustomizer> parse(String line) {
+    protected List<CamelContextCustomizer> parse(Resource resource, String 
line) {
         if (!isModeline(line)) {
             return Collections.emptyList();
         }
@@ -86,7 +86,7 @@ public class ModelineParser {
                 String value = StringHelper.after(part, "=");
                 Trait trait = traits.get(name);
                 if (trait != null) {
-                    CamelContextCustomizer customizer = 
trait.parseTrait(value);
+                    CamelContextCustomizer customizer = 
trait.parseTrait(resource, value);
                     if (customizer != null) {
                         answer.add(customizer);
                     }
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/NameTrait.java
 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/NameTrait.java
index ae93e8d..d59adb7 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/NameTrait.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/NameTrait.java
@@ -19,6 +19,7 @@ package org.apache.camel.dsl.modeline;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.spi.Resource;
 
 public class NameTrait implements Trait {
 
@@ -28,7 +29,7 @@ public class NameTrait implements Trait {
     }
 
     @Override
-    public CamelContextCustomizer parseTrait(String trait) {
+    public CamelContextCustomizer parseTrait(Resource resource, String trait) {
         return new CamelContextCustomizer() {
             @Override
             public void configure(CamelContext camelContext) {
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/PropertyTrait.java
 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/PropertyTrait.java
index 68f2f49..76866da 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/PropertyTrait.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/PropertyTrait.java
@@ -18,15 +18,18 @@ package org.apache.camel.dsl.modeline;
 
 import java.io.InputStream;
 import java.util.Properties;
+import java.util.function.Predicate;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
+import org.apache.camel.Ordered;
 import org.apache.camel.spi.CamelContextCustomizer;
-import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.spi.LoadablePropertiesSource;
 import org.apache.camel.spi.PropertiesSource;
+import org.apache.camel.spi.Resource;
 import org.apache.camel.spi.annotations.JdkService;
 import org.apache.camel.support.ResourceHelper;
-import org.apache.camel.util.OrderedProperties;
+import org.apache.camel.util.OrderedLocationProperties;
 import org.apache.camel.util.StringHelper;
 
 /**
@@ -34,11 +37,15 @@ import org.apache.camel.util.StringHelper;
  * property values.
  */
 @JdkService("properties-source-factory")
-public class PropertyTrait implements Trait, PropertiesSource, 
CamelContextAware {
+public class PropertyTrait implements Trait, LoadablePropertiesSource, 
CamelContextAware, Ordered {
 
-    private final Properties properties = new OrderedProperties();
+    private final OrderedLocationProperties properties = new 
OrderedLocationProperties();
     private CamelContext camelContext;
-    private PropertiesComponent pc;
+
+    @Override
+    public int getOrder() {
+        return 900;
+    }
 
     @Override
     public CamelContext getCamelContext() {
@@ -61,11 +68,11 @@ public class PropertyTrait implements Trait, 
PropertiesSource, CamelContextAware
     }
 
     @Override
-    public CamelContextCustomizer parseTrait(String trait) {
+    public CamelContextCustomizer parseTrait(Resource resource, String trait) {
         if (trait.contains("=")) {
             String key = StringHelper.before(trait, "=").trim();
             String value = StringHelper.after(trait, "=").trim();
-            setProperty(key, value);
+            setProperty(resource, key, value);
         } else {
             if (ResourceHelper.hasScheme(trait)) {
                 // it is a properties file so load resource
@@ -76,7 +83,7 @@ public class PropertyTrait implements Trait, 
PropertiesSource, CamelContextAware
                         String v = prop.getProperty(k);
                         String key = k.trim();
                         String value = v.trim();
-                        setProperty(key, value);
+                        setProperty(resource, key, value);
                     }
                 } catch (Exception e) {
                     // ignore
@@ -86,16 +93,37 @@ public class PropertyTrait implements Trait, 
PropertiesSource, CamelContextAware
         return null;
     }
 
-    protected void setProperty(String key, String value) {
-        properties.setProperty(key, value);
-        if (!camelContext.isStarted()) {
-            // if we are bootstrapping then also set as initial property, so 
it can be used there as well
-            camelContext.getPropertiesComponent().addInitialProperty(key, 
value);
+    protected void setProperty(Resource resource, String key, String value) {
+        String loc = resource.getLocation();
+        properties.put(loc, key, value);
+    }
+
+    @Override
+    public Properties loadProperties() {
+        return properties;
+    }
+
+    @Override
+    public Properties loadProperties(Predicate<String> filter) {
+        OrderedLocationProperties answer = new OrderedLocationProperties();
+
+        for (String name : properties.stringPropertyNames()) {
+            if (filter.test(name)) {
+                answer.put(properties.getLocation(name), name, 
properties.get(name));
+            }
         }
+
+        return answer;
+    }
+
+    @Override
+    public void reloadProperties(String location) {
+        // noop
     }
 
     @Override
     public String toString() {
         return "camel-dsl-modeline";
     }
+
 }
diff --git 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/Trait.java 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/Trait.java
index 77f893c..93473fc 100644
--- 
a/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/Trait.java
+++ 
b/dsl/camel-dsl-modeline/src/main/java/org/apache/camel/dsl/modeline/Trait.java
@@ -17,6 +17,7 @@
 package org.apache.camel.dsl.modeline;
 
 import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.spi.Resource;
 
 /**
  * modeline trait
@@ -27,10 +28,11 @@ public interface Trait {
 
     /**
      * Parses the trait
-     * 
-     * @param  trait the trait
-     * @return       a customizer if the trait is accepted, otherwise null is 
returned
+     *
+     * @param  resource the source
+     * @param  trait    the trait
+     * @return          a customizer if the trait is accepted, otherwise null 
is returned
      */
-    CamelContextCustomizer parseTrait(String trait);
+    CamelContextCustomizer parseTrait(Resource resource, String trait);
 
 }

Reply via email to