CAMEL-8226 Deprecated feature dataSourceRef not working correctly

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

Branch: refs/heads/master
Commit: 649b946a381f40263c2e5414f5d1966a7ef7eec9
Parents: baf9120
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Feb 10 09:18:47 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Feb 10 09:18:47 2015 +0100

----------------------------------------------------------------------
 .../camel/component/sql/SqlComponent.java       | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/649b946a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
index 14ad063..2cdf72f 100755
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
@@ -45,21 +45,23 @@ public class SqlComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+        // endpoint options overrule component configured datasource
         DataSource ds = resolveAndRemoveReferenceParameter(parameters, 
"dataSource", DataSource.class);
-        if (ds != null) {
-            dataSource = ds;
-        }
-
-        //TODO cmueller: remove the 'dataSourceRef' lookup in Camel 3.0
         String dataSourceRef = getAndRemoveParameter(parameters, 
"dataSourceRef", String.class);
-        if (dataSource == null && dataSourceRef != null) {
-                dataSource = 
CamelContextHelper.mandatoryLookup(getCamelContext(), dataSourceRef, 
DataSource.class);
-            }
+        if (ds == null && dataSourceRef != null) {
+            ds = CamelContextHelper.mandatoryLookup(getCamelContext(), 
dataSourceRef, DataSource.class);
+        }
+        if (ds == null) {
+            // fallback and use component
+            ds = dataSource;
+        }
+        if (ds == null) {
+            throw new IllegalArgumentException("DataSource must be 
configured");
         }
 
         String parameterPlaceholderSubstitute = 
getAndRemoveParameter(parameters, "placeholder", String.class, "#");
         
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
         IntrospectionSupport.setProperties(jdbcTemplate, parameters, 
"template.");
 
         String query = remaining.replaceAll(parameterPlaceholderSubstitute, 
"?");

Reply via email to