karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [35/50] [abbrv] karaf git commit: Some optimizations in jdbc
Date Mon, 22 Aug 2016 09:30:33 GMT
Some optimizations in jdbc


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

Branch: refs/heads/master
Commit: e29d9aa8e23adc42cb59d6f2b1258178c66939f2
Parents: 2dd4b48
Author: Christian Schneider <chris@die-schneider.net>
Authored: Fri Aug 12 10:32:08 2016 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Mon Aug 22 11:29:21 2016 +0200

----------------------------------------------------------------------
 .../jdbc/command/ds/DSFactoriesCommand.java     |  3 --
 .../karaf/jdbc/internal/JdbcServiceImpl.java    | 30 ++++++++------------
 2 files changed, 12 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e29d9aa8/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java
index 67f1a2c..9cf5c9d 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java
@@ -17,9 +17,6 @@
 package org.apache.karaf.jdbc.command.ds;
 
 import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.karaf.jdbc.command.JdbcCommandSupport;
 import org.apache.karaf.shell.api.action.Command;

http://git-wip-us.apache.org/repos/asf/karaf/blob/e29d9aa8/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
index 1bd3dd8..922e4d4 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
@@ -63,28 +63,22 @@ public class JdbcServiceImpl implements JdbcService {
         }
         Dictionary<String, String> properties = new Hashtable<String, String>();
         properties.put(DataSourceFactory.JDBC_DATASOURCE_NAME, name);
-        if (driverName != null) {
-            properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, driverName);
-        }
-        if (driverClass != null) {
-            properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, driverClass);
-        }
-        if (databaseName != null) {
-            properties.put(DataSourceFactory.JDBC_DATABASE_NAME, databaseName);
-        }
-        if (url != null) {
-            properties.put(DataSourceFactory.JDBC_URL, url);
-        }
-        if (user != null) {
-            properties.put(DataSourceFactory.JDBC_USER, user);
-        }
-        if (password != null) {
-            properties.put(DataSourceFactory.JDBC_PASSWORD, password);
-        }
+        put(properties, DataSourceFactory.OSGI_JDBC_DRIVER_NAME, driverName);
+        put(properties, DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, driverClass);
+        put(properties, DataSourceFactory.JDBC_DATABASE_NAME, databaseName);
+        put(properties, DataSourceFactory.JDBC_URL, url);
+        put(properties, DataSourceFactory.JDBC_USER, user);
+        put(properties, DataSourceFactory.JDBC_PASSWORD, password);
         Configuration config = configAdmin.createFactoryConfiguration("org.ops4j.datasource",
null);
         config.update(properties);
     }
 
+    private void put(Dictionary<String, String> properties, String key, String value)
{
+        if (value != null) {
+            properties.put(key, value);
+        }
+    }
+
     @Override
     public void delete(String name) throws Exception {
         String filter = String.format("(%s=%s)", DataSourceFactory.JDBC_DATASOURCE_NAME,
name);


Mime
View raw message