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

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


The following commit(s) were added to refs/heads/master by this push:
     new 948c93a  CAMEL-13686: camel-main - Added option to log summary or not.
948c93a is described below

commit 948c93ab444a3cff67f66baf014bb0112d83ce4e
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Jun 28 09:11:26 2019 +0200

    CAMEL-13686: camel-main - Added option to log summary or not.
---
 .../camel/main/MainConfigurationProperties.java    | 26 +++++++++++++++++++++-
 .../java/org/apache/camel/main/MainSupport.java    | 13 ++++++-----
 .../camel-main-configuration-metadata.json         |  9 +++++++-
 .../META-INF/spring-configuration-metadata.json    |  9 +++++++-
 .../META-INF/spring-configuration-metadata.json    |  9 +++++++-
 .../META-INF/spring-configuration-metadata.json    |  9 +++++++-
 6 files changed, 64 insertions(+), 11 deletions(-)

diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index fe3aa8d..ffdca5d 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -24,6 +24,7 @@ public class MainConfigurationProperties extends 
DefaultConfigurationProperties<
     private boolean autoConfigurationEnabled = true;
     private boolean autoConfigurationEnvironmentVariablesEnabled = true;
     private boolean autoConfigurationFailFast = true;
+    private boolean autoConfigurationLogSummary = true;
     private boolean autowireComponentProperties = true;
     private boolean autowireComponentPropertiesDeep;
     private boolean autowireComponentPropertiesAllowPrivateSetter = true;
@@ -59,7 +60,7 @@ public class MainConfigurationProperties extends 
DefaultConfigurationProperties<
     }
 
     /**
-     * Whether auto configuration of components/dataformats/languages is 
enabled or not.
+     * Whether auto configuration of components, dataformats, languages is 
enabled or not.
      * When enabled the configuration parameters are loaded from the 
properties component
      * and optionally from the classpath file 
META-INF/services/org/apache/camel/autowire.properties.
      * You can prefix the parameters in the properties file with:
@@ -111,6 +112,19 @@ public class MainConfigurationProperties extends 
DefaultConfigurationProperties<
         this.autoConfigurationFailFast = autoConfigurationFailFast;
     }
 
+    public boolean isAutoConfigurationLogSummary() {
+        return autoConfigurationLogSummary;
+    }
+
+    /**
+     * Whether auto configuration should log a summary with the configured 
properties.
+     * <p/>
+     * This option is default enabled.
+     */
+    public void setAutoConfigurationLogSummary(boolean 
autoConfigurationLogSummary) {
+        this.autoConfigurationLogSummary = autoConfigurationLogSummary;
+    }
+
     public boolean isAutowireComponentProperties() {
         return autowireComponentProperties;
     }
@@ -227,6 +241,16 @@ public class MainConfigurationProperties extends 
DefaultConfigurationProperties<
     }
 
     /**
+     * Whether auto configuration should log a summary with the configured 
properties.
+     * <p/>
+     * This option is default enabled.
+     */
+    public MainConfigurationProperties withAutoConfigurationLogSummary(boolean 
autoConfigurationLogSummary) {
+        this.autoConfigurationLogSummary = autoConfigurationLogSummary;
+        return this;
+    }
+
+    /**
      * Whether autowiring components with properties that are of same type, 
which has been added to the Camel registry, as a singleton instance.
      * This is used for convention over configuration to inject DataSource, 
AmazonLogin instances to the components.
      * <p/>
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index 2a547f4..ec07882 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -721,7 +721,7 @@ public abstract class MainSupport extends ServiceSupport {
             if (overrideProperties != null) {
                 pc.setOverrideProperties(overrideProperties);
             }
-            LOG.info("Using optional properties from 
classpath:application.properties");
+            LOG.info("Using properties from classpath:application.properties");
         }
 
         if (mainConfigurationProperties.getDurationMaxMessages() > 0 || 
mainConfigurationProperties.getDurationMaxIdleSeconds() > 0) {
@@ -733,6 +733,7 @@ public abstract class MainSupport extends ServiceSupport {
             camelContext.getManagementStrategy().addEventNotifier(notifier);
         }
 
+        // gathers the properties (key=value) that was auto-configured
         final Map<String, String> autoConfiguredProperties = new 
LinkedHashMap<>();
 
         // need to eager allow to auto-configure properties component
@@ -758,7 +759,7 @@ public abstract class MainSupport extends ServiceSupport {
         }
 
         // log summary of configurations
-        if (!autoConfiguredProperties.isEmpty()) {
+        if (mainConfigurationProperties.isAutoConfigurationLogSummary() && 
!autoConfiguredProperties.isEmpty()) {
             LOG.info("Auto-configuration summary:");
             autoConfiguredProperties.forEach((k, v) -> {
                 boolean sensitive = 
k.toLowerCase(Locale.US).contains("password") || k.contains("secret") || 
k.contains("passphrase") || k.contains("token");
@@ -1087,7 +1088,7 @@ public abstract class MainSupport extends ServiceSupport {
                 }
                 String option = dot == -1 ? "" : key.substring(dot + 1);
                 String value = prop.getProperty(key, "");
-                String prefix = dot == -1 ? "" : key.substring(0, dot);
+                String prefix = dot == -1 ? "" : key.substring(0, dot + 1);
                 validateOptionAndValue(key, option, value);
                 PropertyOptionKey pok = new PropertyOptionKey(key, component, 
prefix);
                 Map<String, Object> values = properties.getOrDefault(pok, new 
LinkedHashMap<>());
@@ -1106,7 +1107,7 @@ public abstract class MainSupport extends ServiceSupport {
                 }
                 String option = dot == -1 ? "" : key.substring(dot + 1);
                 String value = prop.getProperty(key, "");
-                String prefix = dot == -1 ? "" : key.substring(0, dot);
+                String prefix = dot == -1 ? "" : key.substring(0, dot + 1);
                 validateOptionAndValue(key, option, value);
                 PropertyOptionKey pok = new PropertyOptionKey(key, dataformat, 
prefix);
                 Map<String, Object> values = properties.getOrDefault(pok, new 
LinkedHashMap<>());
@@ -1126,7 +1127,7 @@ public abstract class MainSupport extends ServiceSupport {
                 }
                 String option = dot == -1 ? "" : key.substring(dot + 1);
                 String value = prop.getProperty(key, "");
-                String prefix = dot == -1 ? "" : key.substring(0, dot);
+                String prefix = dot == -1 ? "" : key.substring(0, dot + 1);
                 validateOptionAndValue(key, option, value);
                 PropertyOptionKey pok = new PropertyOptionKey(key, language, 
prefix);
                 Map<String, Object> values = properties.getOrDefault(pok, new 
LinkedHashMap<>());
@@ -1142,7 +1143,7 @@ public abstract class MainSupport extends ServiceSupport {
 
         for (PropertyOptionKey pok : properties.keySet()) {
             Map<String, Object> values = properties.get(pok);
-            String optionKey = 
pok.getKey().substring(pok.getOptionPrefix().length() + 1);
+            String optionKey = 
pok.getKey().substring(pok.getOptionPrefix().length());
             setPropertiesOnTarget(camelContext, pok.getInstance(), values, 
optionKey, pok.getOptionPrefix(),
                     mainConfigurationProperties.isAutoConfigurationFailFast(), 
true, autoConfiguredProperties);
         }
diff --git 
a/core/camel-main/src/main/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/main/resources/META-INF/camel-main-configuration-metadata.json
index 99336ac..2c18c42 100644
--- 
a/core/camel-main/src/main/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/main/resources/META-INF/camel-main-configuration-metadata.json
@@ -27,7 +27,7 @@
                        "name":"camel.main.auto-configuration-enabled",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
-                       "description":"Whether auto configuration of 
components\/dataformats\/languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
+                       "description":"Whether auto configuration of 
components, dataformats, languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
                        "defaultValue":"true"
                },
                {
@@ -45,6 +45,13 @@
                        "defaultValue":"true"
                },
                {
+                       "name":"camel.main.auto-configuration-log-summary",
+                       "type":"boolean",
+                       
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
+                       "description":"Whether auto configuration should log a 
summary with the configured properties. This option is default enabled.",
+                       "defaultValue":"true"
+               },
+               {
                        "name":"camel.main.auto-startup",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.DefaultConfigurationProperties",
diff --git 
a/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
 
b/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
index 4426d2f..e2830d0 100644
--- 
a/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
+++ 
b/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -167,7 +167,7 @@
                        "name":"camel.main.auto-configuration-enabled",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
-                       "description":"Whether auto configuration of 
components\/dataformats\/languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
+                       "description":"Whether auto configuration of 
components, dataformats, languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
                        "defaultValue":"true"
                },
                {
@@ -185,6 +185,13 @@
                        "defaultValue":"true"
                },
                {
+                       "name":"camel.main.auto-configuration-log-summary",
+                       "type":"boolean",
+                       
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
+                       "description":"Whether auto configuration should log a 
summary with the configured properties. This option is default enabled.",
+                       "defaultValue":"true"
+               },
+               {
                        "name":"camel.main.auto-startup",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.DefaultConfigurationProperties",
diff --git 
a/examples/camel-example-main-tiny/src/main/resources/META-INF/spring-configuration-metadata.json
 
b/examples/camel-example-main-tiny/src/main/resources/META-INF/spring-configuration-metadata.json
index c10d80b..db38795 100644
--- 
a/examples/camel-example-main-tiny/src/main/resources/META-INF/spring-configuration-metadata.json
+++ 
b/examples/camel-example-main-tiny/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -47,7 +47,7 @@
                        "name":"camel.main.auto-configuration-enabled",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
-                       "description":"Whether auto configuration of 
components\/dataformats\/languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
+                       "description":"Whether auto configuration of 
components, dataformats, languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
                        "defaultValue":"true"
                },
                {
@@ -65,6 +65,13 @@
                        "defaultValue":"true"
                },
                {
+                       "name":"camel.main.auto-configuration-log-summary",
+                       "type":"boolean",
+                       
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
+                       "description":"Whether auto configuration should log a 
summary with the configured properties. This option is default enabled.",
+                       "defaultValue":"true"
+               },
+               {
                        "name":"camel.main.auto-startup",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.DefaultConfigurationProperties",
diff --git 
a/examples/camel-example-main/src/main/resources/META-INF/spring-configuration-metadata.json
 
b/examples/camel-example-main/src/main/resources/META-INF/spring-configuration-metadata.json
index c1e44b9..b0453f9 100644
--- 
a/examples/camel-example-main/src/main/resources/META-INF/spring-configuration-metadata.json
+++ 
b/examples/camel-example-main/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -157,7 +157,7 @@
                        "name":"camel.main.auto-configuration-enabled",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
-                       "description":"Whether auto configuration of 
components\/dataformats\/languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
+                       "description":"Whether auto configuration of 
components, dataformats, languages is enabled or not. When enabled the 
configuration parameters are loaded from the properties component and 
optionally from the classpath file 
META-INF\/services\/org\/apache\/camel\/autowire.properties. You can prefix the 
parameters in the properties file with: - camel.component.name.option1=value1 - 
camel.component.name.option2=value2 - camel.dataformat.name.option1=value1 - 
camel.dataformat.name.option2=v [...]
                        "defaultValue":"true"
                },
                {
@@ -175,6 +175,13 @@
                        "defaultValue":"true"
                },
                {
+                       "name":"camel.main.auto-configuration-log-summary",
+                       "type":"boolean",
+                       
"sourceType":"org.apache.camel.main.MainConfigurationProperties",
+                       "description":"Whether auto configuration should log a 
summary with the configured properties. This option is default enabled.",
+                       "defaultValue":"true"
+               },
+               {
                        "name":"camel.main.auto-startup",
                        "type":"boolean",
                        
"sourceType":"org.apache.camel.main.DefaultConfigurationProperties",

Reply via email to