camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-9162: camel-elsql component
Date Mon, 05 Oct 2015 11:33:53 GMT
Repository: camel
Updated Branches:
  refs/heads/master a69028d0e -> 4072a78d4


CAMEL-9162: camel-elsql component


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

Branch: refs/heads/master
Commit: 4072a78d49d304b7db386640cbb66d3df4426e5b
Parents: a69028d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Oct 5 13:35:52 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Oct 5 13:35:52 2015 +0200

----------------------------------------------------------------------
 .../camel/component/elsql/ElsqlComponent.java     |  4 +++-
 .../camel/component/elsql/ElsqlEndpoint.java      | 18 +++++++++++++++---
 .../component/elsql/ElSqlConsumerDeleteTest.java  |  3 ++-
 .../src/test/resources/elsql/delete.elsql         |  4 ++++
 .../src/test/resources/elsql/projects.elsql       |  4 ----
 5 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4072a78d/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
index 1c68612..145dd8e 100644
--- a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
+++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlComponent.java
@@ -136,7 +136,9 @@ public class ElsqlComponent extends UriEndpointComponent {
     }
 
     /**
-     * The resource file which contains the elsql SQL statements to use
+     * The resource file which contains the elsql SQL statements to use. You can specify
multiple resources separated by comma.
+     * The resources are loaded on the classpath by default, you can prefix with <tt>file:</tt>
to load from file system.
+     * Notice you can set this option on the component and then you do not have to configure
this on the endpoint.
      */
     public void setResourceUri(String resourceUri) {
         this.resourceUri = resourceUri;

http://git-wip-us.apache.org/repos/asf/camel/blob/4072a78d/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
index 62a00e7..80bf8e3 100644
--- a/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
+++ b/components/camel-elsql/src/main/java/org/apache/camel/component/elsql/ElsqlEndpoint.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.elsql;
 
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import com.opengamma.elsql.ElSql;
 import com.opengamma.elsql.ElSqlConfig;
@@ -105,8 +107,16 @@ public class ElsqlEndpoint extends DefaultSqlEndpoint {
             elSqlConfig = ElSqlDatabaseVendor.Default.asElSqlConfig();
         }
 
-        URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(),
resourceUri);
-        elSql = ElSql.parse(elSqlConfig, url);
+        // there can be multiple resources
+        // so we have all this lovely code to turn that into an URL[]
+        List<URL> list = new ArrayList<URL>();
+        Iterable it = ObjectHelper.createIterable(resourceUri);
+        for (Object path : it) {
+            URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(),
path.toString());
+            list.add(url);
+        }
+        URL[] urls = list.toArray(new URL[list.size()]);
+        elSql = ElSql.parse(elSqlConfig, urls);
     }
 
     /**
@@ -143,7 +153,9 @@ public class ElsqlEndpoint extends DefaultSqlEndpoint {
     }
 
     /**
-     * The resource file which contains the elsql SQL statements to use
+     * The resource file which contains the elsql SQL statements to use. You can specify
multiple resources separated by comma.
+     * The resources are loaded on the classpath by default, you can prefix with <tt>file:</tt>
to load from file system.
+     * Notice you can set this option on the component and then you do not have to configure
this on the endpoint.
      */
     public void setResourceUri(String resourceUri) {
         this.resourceUri = resourceUri;

http://git-wip-us.apache.org/repos/asf/camel/blob/4072a78d/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
index a381bf5..d522854 100644
--- a/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
+++ b/components/camel-elsql/src/test/java/org/apache/camel/component/elsql/ElSqlConsumerDeleteTest.java
@@ -91,8 +91,9 @@ public class ElSqlConsumerDeleteTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 getContext().getComponent("elsql", ElsqlComponent.class).setDataSource(db);
+                getContext().getComponent("elsql", ElsqlComponent.class).setResourceUri("elsql/projects.elsql,elsql/delete.elsql");
 
-                from("elsql:allProjects:elsql/projects.elsql?consumer.onConsume=deleteProject")
+                from("elsql:allProjects?consumer.onConsume=deleteProject")
                         .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/4072a78d/components/camel-elsql/src/test/resources/elsql/delete.elsql
----------------------------------------------------------------------
diff --git a/components/camel-elsql/src/test/resources/elsql/delete.elsql b/components/camel-elsql/src/test/resources/elsql/delete.elsql
new file mode 100644
index 0000000..e9fd60b
--- /dev/null
+++ b/components/camel-elsql/src/test/resources/elsql/delete.elsql
@@ -0,0 +1,4 @@
+@NAME(deleteProject)
+  DELETE
+  FROM projects
+  WHERE id = :id

http://git-wip-us.apache.org/repos/asf/camel/blob/4072a78d/components/camel-elsql/src/test/resources/elsql/projects.elsql
----------------------------------------------------------------------
diff --git a/components/camel-elsql/src/test/resources/elsql/projects.elsql b/components/camel-elsql/src/test/resources/elsql/projects.elsql
index 8cc1a8b..ffc4192 100644
--- a/components/camel-elsql/src/test/resources/elsql/projects.elsql
+++ b/components/camel-elsql/src/test/resources/elsql/projects.elsql
@@ -7,7 +7,3 @@
   SELECT *
   FROM projects
   ORDER BY id
-@NAME(deleteProject)
-  DELETE
-  FROM projects
-  WHERE id = :id


Mime
View raw message