CAMEL-8307: Properties component when using XML should allow specifying 
multiple locations using new lines.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/eb033ec0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/eb033ec0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/eb033ec0

Branch: refs/heads/camel-2.14.x
Commit: eb033ec0d4a9c3ca4b513e5c33be8bd98116ddc4
Parents: 717c62c
Author: Claus Ibsen <[email protected]>
Authored: Mon Feb 2 18:46:40 2015 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Mon Feb 2 18:47:05 2015 +0100

----------------------------------------------------------------------
 .../camel/component/properties/PropertiesComponent.java     | 9 +++++++++
 .../component/properties/SpringPropertiesComponentTest.xml  | 5 ++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eb033ec0/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
 
b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
index 9cd3f92..520c4d0 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java
@@ -193,6 +193,15 @@ public class PropertiesComponent extends DefaultComponent {
     }
 
     public void setLocations(String[] locations) {
+        // make sure to trim as people may use new lines when configuring 
using XML
+        // and do this in the setter as Spring/Blueprint resolves placeholders 
before Camel is being started
+        if (locations != null && locations.length > 0) {
+            for (int i = 0; i < locations.length; i++) {
+                String loc = locations[i];
+                locations[i] = loc.trim();
+            }
+        }
+
         this.locations = locations;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/eb033ec0/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
index 8a408aa..1357998 100644
--- 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
@@ -22,8 +22,11 @@
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
+    <!-- define the locations using multi line to test that it works also -->
     <bean id="properties" 
class="org.apache.camel.component.properties.PropertiesComponent">
-        <property name="location" 
value="classpath:org/apache/camel/component/properties/cheese.properties"/>
+        <property name="location" value="
+            classpath:org/apache/camel/component/properties/myprop.properties,
+            
classpath:org/apache/camel/component/properties/cheese.properties"/>
     </bean>
 
     <camelContext autoStartup="{{autoStartup}}" 
xmlns="http://camel.apache.org/schema/spring";>

Reply via email to