You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/10/12 05:42:26 UTC

[camel] branch main updated (155a0591ca8 -> c14f001c7dc)

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

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


    from 155a0591ca8 CAMEL-18600: properties component - Allow to turn off nested placeholders
     new 127a3316e79 CAMEL-18600: properties component - Allow to turn off nested placeholders
     new c14f001c7dc CAMEL-18600: properties component - Allow to turn off nested placeholders

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


Summary of changes:
 components/camel-jasypt/src/main/docs/jasypt.adoc       | 13 +++++++++----
 .../camel/component/jasypt/JasyptPropertiesTest.java    |  2 ++
 .../jasypt/SpringJasyptBridgePropertiesAutowireTest.xml |  6 ++++++
 .../jasypt/SpringJasyptBridgePropertiesTest.xml         |  6 ++++++
 .../component/jasypt/SpringJasyptProperties2Test.xml    |  1 +
 .../component/jasypt/SpringJasyptPropertiesTest.xml     |  2 ++
 .../camel/component/properties/PropertiesComponent.java | 17 -----------------
 .../org/apache/camel/core/xml/propertyPlaceholder.json  |  1 +
 .../camel/core/xml/AbstractCamelContextFactoryBean.java |  3 +++
 .../core/xml/CamelPropertyPlaceholderDefinition.java    | 15 +++++++++++++++
 10 files changed, 45 insertions(+), 21 deletions(-)


[camel] 01/02: CAMEL-18600: properties component - Allow to turn off nested placeholders

Posted by da...@apache.org.
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

commit 127a3316e798f546d7a6cbd2535b2a6e8abd25bb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Oct 12 07:36:13 2022 +0200

    CAMEL-18600: properties component - Allow to turn off nested placeholders
---
 components/camel-jasypt/src/main/docs/jasypt.adoc         | 13 +++++++++----
 .../camel/component/jasypt/JasyptPropertiesTest.java      |  2 ++
 .../jasypt/SpringJasyptBridgePropertiesAutowireTest.xml   |  6 ++++++
 .../component/jasypt/SpringJasyptBridgePropertiesTest.xml |  6 ++++++
 .../component/jasypt/SpringJasyptProperties2Test.xml      |  1 +
 .../camel/component/jasypt/SpringJasyptPropertiesTest.xml |  2 ++
 .../org/apache/camel/core/xml/propertyPlaceholder.json    |  1 +
 .../camel/core/xml/AbstractCamelContextFactoryBean.java   |  3 +++
 .../core/xml/CamelPropertyPlaceholderDefinition.java      | 15 +++++++++++++++
 9 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/components/camel-jasypt/src/main/docs/jasypt.adoc b/components/camel-jasypt/src/main/docs/jasypt.adoc
index b100c09d4f9..ba167e8484d 100644
--- a/components/camel-jasypt/src/main/docs/jasypt.adoc
+++ b/components/camel-jasypt/src/main/docs/jasypt.adoc
@@ -132,15 +132,15 @@ mandatory. See below for more details.
 == Protecting the master password
 
 The master password used by Jasypt must be provided,
-so that it's capable of decrypting the values. However having this
-master password out in the open may not be an ideal solution. Therefore
-you could for example provide it as a JVM system property or as a OS
+so that it's capable of decrypting the values. However, having this
+master password out in the open may not be an ideal solution. Therefore,
+you could for example provide it as a JVM system property or as an OS
 environment setting. If you decide to do so then the `password` option
 supports prefixes which dictates this. `sysenv:` means to lookup the OS
 system environment with the given key. `sys:` means to lookup a JVM
 system property.
 
-For example you could provided the password before you start the
+For example, you could provide the password before you start the
 application
 
 [source,bash]
@@ -191,6 +191,8 @@ the properties.
     <property name="location" value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
     <!-- and let it leverage the jasypt parser -->
     <property name="propertiesParser" ref="jasypt"/>
+    <!-- end enable nested placeholder -->
+    <property name="nestedPlaceholder" value="true"/>
 </bean>
 -----------------------------------------------------------------------------------------------------------
 
@@ -212,6 +214,7 @@ Jasypt.
     <!-- define the camel properties placeholder, and let it leverage jasypt -->
     <propertyPlaceholder id="properties"
                          location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+                         nestedPlaceholder="true"
                          propertiesParserRef="jasypt"/>
     <route>
         <from uri="direct:start"/>
@@ -254,6 +257,7 @@ up in the properties.
       <!-- define the camel properties placeholder, and let it leverage jasypt -->
       <propertyPlaceholder id="properties"
                            location="blueprint:myblue"
+                           nestedPlaceholder="true"
                            propertiesParserRef="jasypt"/>
         <route>
             <from uri="direct:start"/>
@@ -286,6 +290,7 @@ to Jasypt.
       <!-- define the camel properties placeholder, and let it leverage jasypt -->
       <propertyPlaceholder id="properties"
                            location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+                           nestedPlaceholder="true"
                            propertiesParserRef="jasypt"/>
         <route>
             <from uri="direct:start"/>
diff --git a/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/JasyptPropertiesTest.java b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/JasyptPropertiesTest.java
index 28b6e6359d9..88093eb740a 100644
--- a/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/JasyptPropertiesTest.java
+++ b/components/camel-jasypt/src/test/java/org/apache/camel/component/jasypt/JasyptPropertiesTest.java
@@ -49,6 +49,8 @@ public class JasyptPropertiesTest extends CamelTestSupport {
         pc.setLocation("classpath:org/apache/camel/component/jasypt/myproperties.properties");
         // and use the jasypt properties parser so we can decrypt values
         pc.setPropertiesParser(jasypt);
+        // end enable nested placeholder
+        pc.setNestedPlaceholder(true);
 
         // add properties component to camel context
         context.setPropertiesComponent(pc);
diff --git a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesAutowireTest.xml b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesAutowireTest.xml
index 0306b15dd24..a332f39fcdb 100644
--- a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesAutowireTest.xml
+++ b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesAutowireTest.xml
@@ -36,6 +36,12 @@
     <property name="password" value="secret" />
   </bean>
 
+  <!-- define the camel properties component -->
+  <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
+    <!-- enable nested placeholder -->
+    <property name="nestedPlaceholder" value="true"/>
+  </bean>
+
   <!-- bridge to spring property placeholder -->
   <bean id="bridgePropertyPlaceholder"
     class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
diff --git a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
index bbfd54705af..cc95f355fac 100644
--- a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
+++ b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptBridgePropertiesTest.xml
@@ -29,6 +29,12 @@
     <property name="password" value="secret"/>
   </bean>
 
+  <!-- define the camel properties component -->
+  <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
+    <!-- enable nested placeholder -->
+    <property name="nestedPlaceholder" value="true"/>
+  </bean>
+
   <!-- bridge to spring property placeholder -->
   <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
     <property name="location" value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
diff --git a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptProperties2Test.xml b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptProperties2Test.xml
index 5496c994429..c9bd62ca33a 100644
--- a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptProperties2Test.xml
+++ b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptProperties2Test.xml
@@ -36,6 +36,7 @@
         <!-- define the camel properties placeholder, and let it leverage jasypt -->
         <propertyPlaceholder id="properties"
                              location="classpath:org/apache/camel/component/jasypt/myproperties.properties"
+                             nestedPlaceholder="true"
                              propertiesParserRef="jasypt"/>
         <route>
             <from uri="direct:start"/>
diff --git a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptPropertiesTest.xml b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptPropertiesTest.xml
index 74263f7f5ad..24a993d3eb0 100644
--- a/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptPropertiesTest.xml
+++ b/components/camel-jasypt/src/test/resources/org/apache/camel/component/jasypt/SpringJasyptPropertiesTest.xml
@@ -36,6 +36,8 @@
         <property name="location" value="classpath:org/apache/camel/component/jasypt/myproperties.properties"/>
         <!-- and let it leverage the jasypt parser -->
         <property name="propertiesParser" ref="jasypt"/>
+        <!-- end enable nested placeholder -->
+        <property name="nestedPlaceholder" value="true"/>
     </bean>
     <!-- END SNIPPET: e1 -->
 
diff --git a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/propertyPlaceholder.json b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/propertyPlaceholder.json
index 8d8df0b018d..37e42375ad0 100644
--- a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/propertyPlaceholder.json
+++ b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/propertyPlaceholder.json
@@ -15,6 +15,7 @@
     "location": { "kind": "attribute", "displayName": "Location", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option." },
     "encoding": { "kind": "attribute", "displayName": "Encoding", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by java.util.Properties#load(java.io.InputStream)" },
     "ignoreMissingLocation": { "kind": "attribute", "displayName": "Ignore Missing Location", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to silently ignore if a location cannot be located, such as a properties file not found." },
+    "nestedPlaceholder": { "kind": "attribute", "displayName": "Nested Placeholder", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to support nested property placeholders. A nested placeholder, means that a placeholder, has also a placeholder, that should be resolved (recursively)." },
     "propertiesParserRef": { "kind": "attribute", "displayName": "Properties Parser Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Reference to a custom PropertiesParser to be used" },
     "defaultFallbackEnabled": { "kind": "attribute", "displayName": "Default Fallback Enabled", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If false, the component does not attempt to find a default for the key by looking after the colon separator." },
     "propertiesFunction": { "kind": "element", "displayName": "Properties Function", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.core.xml.CamelPropertyPlaceholderFunctionDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "List of custom properties function to use." },
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index e6fe2111520..4d4a8e0797a 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -889,6 +889,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
             if (def.isIgnoreMissingLocation() != null) {
                 pc.setIgnoreMissingLocation(def.isIgnoreMissingLocation());
             }
+            if (def.isNestedPlaceholder() != null) {
+                pc.setNestedPlaceholder(def.isNestedPlaceholder());
+            }
 
             // if using a custom parser
             if (org.apache.camel.util.ObjectHelper.isNotEmpty(def.getPropertiesParserRef())) {
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
index 402c56d7254..b191e2f659d 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelPropertyPlaceholderDefinition.java
@@ -43,6 +43,9 @@ public class CamelPropertyPlaceholderDefinition extends IdentifiedType {
     @Metadata(defaultValue = "false")
     private Boolean ignoreMissingLocation;
     @XmlAttribute
+    @Metadata(defaultValue = "true")
+    private Boolean nestedPlaceholder;
+    @XmlAttribute
     private String propertiesParserRef;
     @XmlAttribute
     @Metadata(defaultValue = "true")
@@ -111,6 +114,18 @@ public class CamelPropertyPlaceholderDefinition extends IdentifiedType {
         this.ignoreMissingLocation = ignoreMissingLocation;
     }
 
+    public Boolean isNestedPlaceholder() {
+        return nestedPlaceholder;
+    }
+
+    /**
+     * Whether to support nested property placeholders. A nested placeholder, means that a placeholder, has also a
+     * placeholder, that should be resolved (recursively).
+     */
+    public void setNestedPlaceholder(Boolean nestedPlaceholder) {
+        this.nestedPlaceholder = nestedPlaceholder;
+    }
+
     public List<CamelPropertyPlaceholderFunctionDefinition> getFunctions() {
         return functions;
     }


[camel] 02/02: CAMEL-18600: properties component - Allow to turn off nested placeholders

Posted by da...@apache.org.
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

commit c14f001c7dce8711278b711677a3e210d6bd2e1a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Oct 12 07:42:16 2022 +0200

    CAMEL-18600: properties component - Allow to turn off nested placeholders
---
 .../camel/component/properties/PropertiesComponent.java | 17 -----------------
 1 file changed, 17 deletions(-)

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 da06caa6b2e..02888ccd9ed 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
@@ -455,9 +455,6 @@ public class PropertiesComponent extends ServiceSupport
         return ignoreMissingLocation;
     }
 
-    /**
-     * Whether to silently ignore if a location cannot be located, such as a properties file not found.
-     */
     @Override
     public void setIgnoreMissingLocation(boolean ignoreMissingLocation) {
         this.ignoreMissingLocation = ignoreMissingLocation;
@@ -468,10 +465,6 @@ public class PropertiesComponent extends ServiceSupport
         return nestedPlaceholder;
     }
 
-    /**
-     * Whether to support nested property placeholders. A nested placeholder, means that a placeholder, has also a
-     * placeholder, that should be resolved (recursively).
-     */
     @Override
     public void setNestedPlaceholder(boolean nestedPlaceholder) {
         this.nestedPlaceholder = nestedPlaceholder;
@@ -488,9 +481,6 @@ public class PropertiesComponent extends ServiceSupport
         return initialProperties;
     }
 
-    /**
-     * Sets initial properties which will be used before any locations are resolved.
-     */
     @Override
     public void setInitialProperties(Properties initialProperties) {
         this.initialProperties = initialProperties;
@@ -515,9 +505,6 @@ public class PropertiesComponent extends ServiceSupport
         return overrideProperties;
     }
 
-    /**
-     * Sets a special list of override properties that take precedence and will use first, if a property exists.
-     */
     @Override
     public void setOverrideProperties(Properties overrideProperties) {
         this.overrideProperties = overrideProperties;
@@ -532,10 +519,6 @@ public class PropertiesComponent extends ServiceSupport
 
     }
 
-    /**
-     * Sets a special list of local properties (ie thread local) that take precedence and will use first, if a property
-     * exists.
-     */
     @Override
     public void setLocalProperties(Properties localProperties) {
         if (localProperties != null) {