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 2016/08/29 07:00:35 UTC
camel git commit: CAMEL-10255 - Make it easy to configure property
placeholder
Repository: camel
Updated Branches:
refs/heads/master e8551a8be -> 38cb20834
CAMEL-10255 - Make it easy to configure property placeholder
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/38cb2083
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/38cb2083
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/38cb2083
Branch: refs/heads/master
Commit: 38cb20834dd90b2a485f77d676d15e3a1f0232f3
Parents: e8551a8
Author: Darius <da...@gmail.com>
Authored: Sun Aug 28 14:11:47 2016 -0400
Committer: Darius <da...@gmail.com>
Committed: Sun Aug 28 15:28:30 2016 -0400
----------------------------------------------------------------------
camel-core/src/main/java/org/apache/camel/main/Main.java | 10 ++++++++++
.../src/test/java/org/apache/camel/main/MainExample.java | 5 +++--
camel-core/src/test/resources/example.properties | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/38cb2083/camel-core/src/main/java/org/apache/camel/main/Main.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/main/Main.java b/camel-core/src/main/java/org/apache/camel/main/Main.java
index 2840a86..0c12d6d 100644
--- a/camel-core/src/main/java/org/apache/camel/main/Main.java
+++ b/camel-core/src/main/java/org/apache/camel/main/Main.java
@@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.properties.PropertiesComponent;
import org.apache.camel.impl.CompositeRegistry;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.SimpleRegistry;
@@ -174,4 +175,13 @@ public class Main extends MainSupport {
return new DefaultCamelContext();
}
+ /**
+ * 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.
+ */
+ protected void setPropertyPlaceholderLocations(String location) {
+ PropertiesComponent pc = new PropertiesComponent();
+ pc.setLocation(location);
+ bind("properties", pc);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/38cb2083/camel-core/src/test/java/org/apache/camel/main/MainExample.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/main/MainExample.java b/camel-core/src/test/java/org/apache/camel/main/MainExample.java
index e4c7303..da52edc 100644
--- a/camel-core/src/test/java/org/apache/camel/main/MainExample.java
+++ b/camel-core/src/test/java/org/apache/camel/main/MainExample.java
@@ -44,7 +44,8 @@ public class MainExample {
main.addRouteBuilder(new MyRouteBuilder());
// add event listener
main.addMainListener(new Events());
-
+ // set the properties from a file
+ main.setPropertyPlaceholderLocations("example.properties");
// run until you terminate the JVM
System.out.println("Starting Camel. Use ctrl + c to terminate the JVM.\n");
main.run();
@@ -53,7 +54,7 @@ public class MainExample {
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
- from("timer:foo?delay=2000")
+ from("timer:foo?delay={{millisecs}}")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Invoked timer at " + new Date());
http://git-wip-us.apache.org/repos/asf/camel/blob/38cb2083/camel-core/src/test/resources/example.properties
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/example.properties b/camel-core/src/test/resources/example.properties
new file mode 100644
index 0000000..7b513cc
--- /dev/null
+++ b/camel-core/src/test/resources/example.properties
@@ -0,0 +1 @@
+millisecs=2000