You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2015/02/04 14:48:57 UTC

karaf git commit: [KARAF-3478] Use pax-jdbc config in jdbc commands

Repository: karaf
Updated Branches:
  refs/heads/jdbc-commands [created] e3949f575


[KARAF-3478] Use pax-jdbc config in jdbc commands


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

Branch: refs/heads/jdbc-commands
Commit: e3949f575770aa609cc8bc86d6e1037430b405f5
Parents: 471b923
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Wed Feb 4 14:46:37 2015 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Wed Feb 4 14:46:37 2015 +0100

----------------------------------------------------------------------
 jdbc/pom.xml                                    |  10 +-
 .../java/org/apache/karaf/jdbc/JdbcMBean.java   |  18 +-
 .../java/org/apache/karaf/jdbc/JdbcService.java |  46 ++--
 .../karaf/jdbc/command/CreateCommand.java       |  61 -----
 .../karaf/jdbc/command/DataSourcesCommand.java  |  64 ------
 .../karaf/jdbc/command/DeleteCommand.java       |  39 ----
 .../apache/karaf/jdbc/command/InfoCommand.java  |  53 -----
 .../DataSourcesFileNameCompleter.java           |   8 +-
 .../karaf/jdbc/command/ds/CreateCommand.java    |  55 +++++
 .../jdbc/command/ds/DSFactoriesCommand.java     |  57 +++++
 .../ds/DataSourceFactoryNamesCompleter.java     |  59 +++++
 .../karaf/jdbc/command/ds/DeleteCommand.java    |  40 ++++
 .../karaf/jdbc/command/ds/InfoCommand.java      |  54 +++++
 .../karaf/jdbc/command/ds/ListCommand.java      |  54 +++++
 .../karaf/jdbc/internal/JdbcConnector.java      |   5 +-
 .../karaf/jdbc/internal/JdbcMBeanImpl.java      |   7 +-
 .../karaf/jdbc/internal/JdbcServiceImpl.java    | 226 +++++++------------
 .../karaf/jdbc/internal/osgi/Activator.java     |   9 +-
 pom.xml                                         |   2 +-
 19 files changed, 459 insertions(+), 408 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index d98ef28..d56e910 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -45,6 +45,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.enterprise</artifactId>
+            <version>5.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.karaf</groupId>
             <artifactId>org.apache.karaf.util</artifactId>
         </dependency>
@@ -82,10 +88,12 @@
                 <configuration>
                     <instructions>
                         <Export-Package>
-                            org.apache.karaf.jdbc
+                            org.apache.karaf.jdbc,
+                            org.osgi.service.jdbc
                         </Export-Package>
                         <Private-Package>
                             org.apache.karaf.jdbc.command,
+                            org.apache.karaf.jdbc.command.ds,
                             org.apache.karaf.jdbc.command.completers,
                             org.apache.karaf.jdbc.command.parsing,
                             org.apache.karaf.jdbc.internal,

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java b/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
index 26165c8..35a48cb 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
@@ -18,6 +18,7 @@ package org.apache.karaf.jdbc;
 
 import javax.management.MBeanException;
 import javax.management.openmbean.TabularData;
+
 import java.util.Map;
 
 /**
@@ -36,17 +37,16 @@ public interface JdbcMBean {
     /**
      * Create a JDBC datasource.
      *
-     * @param name the JDBC datasource name.
-     * @param type the JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL).
-     * @param driver the JDBC datasource driver class name (can be null).
-     * @param version the target JDBC driver version (can be null).
-     * @param url the JDBC URL.
-     * @param user the database username.
-     * @param password the database password.
-     * @param installBundles true to install the bundles providing the JDBC driver, false to not install.
+     * @param name the JDBC datasource name
+     * @param driverName org.osgi.driver.name of the DataSourceFactory to use
+     * @param driverClass org.osgi.driver.class of the DataSourceFactory to use
+     * @param databaseName name of the database to access
+     * @param url JDBC URL
+     * @param user Database username
+     * @param password Database password
      * @throws MBeanException
      */
-    void create(String name, String type, String driver, String version, String url, String user, String password, boolean installBundles) throws MBeanException;
+    void create(String name, String driverName, String driverClass, String databaseName, String url, String user, String password) throws MBeanException;
 
     /**
      * Delete a JDBC datasource.

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcService.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcService.java b/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcService.java
index b99c95e..1f4b27b 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcService.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/JdbcService.java
@@ -18,7 +18,6 @@ package org.apache.karaf.jdbc;
 
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * JDBC Service.
@@ -26,47 +25,38 @@ import java.util.Set;
 public interface JdbcService {
 
     /**
-     * Create a JDBC datasource (using a default template).
+     * Create a JDBC datasource configuration.
      *
-     * @param name the JDBC datasource name.
-     * @param type the backend database type (generic, Oracle, MySQL, ...)
-     * @param driverClassName the JDBC driver classname.
-     * @param version the JDBC driver version to use.
-     * @param url the JDBC URL.
-     * @param user the database user name.
-     * @param password the database password.
-     * @param tryToInstallBundles true to try to automatically install the required bundles (JDBC driver, etc) when possible, false else.
+     * @param name Datasource name 
+     * @param driverName Backend database type (osgi.jdbc.driver.name of DataSourceFactory)
+     * @param url JDBC URL
+     * @param user Database user name
+     * @param password Database password
+     * @param password2 
      */
-    void create(String name, String type, String driverClassName, String version, String url, String user, String password, boolean tryToInstallBundles) throws Exception;
+    void create(String name, String driverName, String driverClass, String databaseName, String url, String user, String password) throws Exception;
 
     /**
-     * Delete a JDBC datasource identified by a name.
+     * Delete a JDBC datasource identified by a name. Works only
+     * for datasources that have a corresponding configuration
      *
-     * @param name the JDBC datasource name.
+     * @param name Datasource name
      */
     void delete(String name) throws Exception;
-
+    
     /**
-     * List the JDBC datasources available.
+     * List the JDBC DataSourceFactories available.
      *
-     * @return a list of datasources name.
+     * @return a list of DataSourceFactory names
      */
-    List<String> datasources() throws Exception;
+    List<String> factoryNames() throws Exception;
 
     /**
-     * List the datasources available and
-     * group aliases for the same datasource.
-     *
-     * @return a list of aliases.
-     */
-    Map<String, Set<String>> aliases() throws Exception;
-
-    /**
-     * List the JDBC datasources configuration file names present in the deploy folder.
+     * List the JDBC datasources available.
      *
-     * @return a list of the JDBC datasources configuration file names.
+     * @return a list of datasources names
      */
-    List<String> datasourceFileNames() throws Exception;
+    List<String> datasources() throws Exception;
 
     /**
      * Execute a SQL query on a given JDBC datasource.

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
deleted file mode 100644
index 89ed49c..0000000
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.jdbc.command;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Completion;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.completers.StringsCompleter;
-
-@Command(scope = "jdbc", name = "create", description = "Create a JDBC datasource")
-@Service
-public class CreateCommand extends JdbcCommandSupport {
-
-    @Argument(index = 0, name = "name", description = "The JDBC datasource name", required = true, multiValued = false)
-    String name;
-
-    @Option(name = "-t", aliases = { "--type" }, description = "The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL)", required = false, multiValued = false)
-    @Completion(value = StringsCompleter.class, values = { "db2", "derby", "generic", "h2", "hsql", "mysql", "oracle", "postgres", "mssql" })
-    String type;
-
-    @Option(name = "-d", aliases = { "--driver" }, description = "The classname of the JDBC driver to use. NB: this option is used only the type generic", required = false, multiValued = false)
-    String driver;
-
-    @Option(name = "-v", aliases = { "--version" }, description = "The version of the driver to use", required = false, multiValued = false)
-    String version;
-
-    @Option(name = "-url", description = "The JDBC URL to use", required = false, multiValued = false)
-    String url;
-
-    @Option(name = "-u", aliases = { "--username" }, description = "The database username", required = false, multiValued = false)
-    String username;
-
-    @Option(name = "-p", aliases = { "--password" }, description = "The database password", required = false, multiValued = false)
-    String password;
-
-    @Option(name = "-i", aliases = { "--install-bundles" }, description = "Try to install the bundles providing the JDBC driver", required = false, multiValued = false)
-    boolean installBundles = false;
-
-    @Override
-    public Object execute() throws Exception {
-        this.getJdbcService().create(name, type, driver, version, url, username, password, installBundles);
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
deleted file mode 100644
index 709a84c..0000000
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.jdbc.command;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.table.ShellTable;
-
-@Command(scope = "jdbc", name = "datasources", description = "List the JDBC datasources")
-@Service
-public class DataSourcesCommand extends JdbcCommandSupport {
-
-    @Override
-    public Object execute() throws Exception {
-        ShellTable table = new ShellTable();
-
-        table.column("Name");
-        table.column("Product");
-        table.column("Version");
-        table.column("URL");
-        table.column("Status");
-
-        Map<String, Set<String>> datasources = this.getJdbcService().aliases();
-        for (Map.Entry<String, Set<String>> entry : datasources.entrySet()) {
-            StringBuilder ids = new StringBuilder();
-            for (String id : entry.getValue()) {
-                if (ids.length() > 0) {
-                    ids.append(", ");
-                }
-                ids.append(id);
-            }
-            String id = ids.toString();
-            try {
-                Map<String, String> info = this.getJdbcService().info(entry.getKey());
-                table.addRow().addContent(id, info.get("db.product"), info.get("db.version"), info.get("url"), "OK");
-            } catch (Exception e) {
-                table.addRow().addContent(id, "", "", "", "Error");
-            }
-        }
-
-        table.print(System.out);
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
deleted file mode 100644
index 6bf7236..0000000
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.jdbc.command;
-
-import org.apache.karaf.jdbc.command.completers.DataSourcesFileNameCompleter;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Completion;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-
-@Command(scope = "jdbc", name = "delete", description = "Delete a JDBC datasource")
-@Service
-public class DeleteCommand extends JdbcCommandSupport {
-
-    @Argument(index = 0, name = "name", description = "The JDBC datasource name (the one used at creation time)", required = true, multiValued = false)
-    @Completion(DataSourcesFileNameCompleter.class)
-    String name;
-
-    @Override
-    public Object execute() throws Exception {
-        this.getJdbcService().delete(name);
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
deleted file mode 100644
index e53bbab..0000000
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.jdbc.command;
-
-import org.apache.karaf.jdbc.command.completers.DataSourcesNameCompleter;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Completion;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.table.ShellTable;
-
-import java.util.Map;
-
-@Command(scope = "jdbc", name = "info", description = "Display details about a JDBC datasource")
-@Service
-public class InfoCommand extends JdbcCommandSupport {
-
-    @Argument(index = 0, name = "datasource", description = "The JDBC datasource name", required = true, multiValued = false)
-    @Completion(DataSourcesNameCompleter.class)
-    String datasource;
-
-    @Override
-    public Object execute() throws Exception {
-        ShellTable table = new ShellTable();
-
-        table.column("Property");
-        table.column("Value");
-
-        Map<String, String> info = this.getJdbcService().info(datasource);
-        for (String property : info.keySet()) {
-            table.addRow().addContent(property, info.get(property));
-        }
-
-        table.print(System.out);
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
index 8ba0fe9..98fcb38 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
@@ -39,8 +39,8 @@ public class DataSourcesFileNameCompleter implements Completer {
     public int complete(Session session, CommandLine commandLine, List<String> candidates) {
         StringsCompleter delegate = new StringsCompleter();
         try {
-            for (String datasourceFileName : jdbcService.datasourceFileNames()) {
-                delegate.getStrings().add(datasourceFileName.replace("datasource-", "").replace(".xml", ""));
+            for (String datasourceFileName : jdbcService.datasources()) {
+                delegate.getStrings().add(datasourceFileName);
             }
         } catch (Exception e) {
             // nothing to do
@@ -48,10 +48,6 @@ public class DataSourcesFileNameCompleter implements Completer {
         return delegate.complete(session, commandLine, candidates);
     }
 
-    public JdbcService getJdbcService() {
-        return jdbcService;
-    }
-
     public void setJdbcService(JdbcService jdbcService) {
         this.jdbcService = jdbcService;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/CreateCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/CreateCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/CreateCommand.java
new file mode 100644
index 0000000..45ceadc
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/CreateCommand.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.jdbc.command.ds;
+
+import org.apache.karaf.jdbc.command.JdbcCommandSupport;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "jdbc", name = "ds-create", description = "Create a JDBC datasource config for pax-jdbc-config from a DataSourceFactory")
+@Service
+public class CreateCommand extends JdbcCommandSupport {
+    @Argument(index = 0, name = "name", description = "The JDBC datasource name", required = true, multiValued = false)
+    String name;
+    
+    @Option(name = "-dn", aliases = { "--driverName" }, description = "org.osgi.driver.name property of the DataSourceFactory", required = false, multiValued = false)
+    String driverName;
+    
+    @Option(name = "-dc", aliases = { "--driverClass" }, description = "org.osgi.driver.class property  of the DataSourceFactory", required = false, multiValued = false)
+    String driverClass;
+
+    @Option(name = "-dbName", description = "Database name to use", required = false, multiValued = false)
+    String databaseName;
+    
+    @Option(name = "-url", description = "The JDBC URL to use", required = false, multiValued = false)
+    String url;
+
+    @Option(name = "-u", aliases = { "--username" }, description = "The database username", required = false, multiValued = false)
+    String username;
+
+    @Option(name = "-p", aliases = { "--password" }, description = "The database password", required = false, multiValued = false)
+    String password;
+
+    @Override
+    public Object execute() throws Exception {
+        this.getJdbcService().create(name, driverName, driverClass, databaseName, url, username, password);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/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
new file mode 100644
index 0000000..67f1a2c
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DSFactoriesCommand.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.jdbc.DataSourceFactory;
+
+@Command(scope = "jdbc", name = "ds-factories", description = "List the JDBC DataSourceFactories")
+@Service
+public class DSFactoriesCommand extends JdbcCommandSupport {
+
+    @Reference
+    BundleContext context;
+    
+    @Override
+    public Object execute() throws Exception {
+        ShellTable table = new ShellTable();
+        table.column("Name");
+        table.column("Class");
+        table.column("Version");
+        Collection<ServiceReference<DataSourceFactory>> refs = context.getServiceReferences(DataSourceFactory.class, null);
+        for (ServiceReference<DataSourceFactory> ref : refs) {
+            String driverName = (String)ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_NAME);
+            String driverClass = (String)ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS);
+            String driverVersion = (String)ref.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION);
+            table.addRow().addContent(driverName, driverClass, driverVersion);
+        }
+        table.print(System.out);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DataSourceFactoryNamesCompleter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DataSourceFactoryNamesCompleter.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DataSourceFactoryNamesCompleter.java
new file mode 100644
index 0000000..6a6784a
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DataSourceFactoryNamesCompleter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.jdbc.command.ds;
+
+import org.apache.karaf.jdbc.JdbcService;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.CommandLine;
+import org.apache.karaf.shell.api.console.Completer;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.support.completers.StringsCompleter;
+
+import java.util.List;
+
+/**
+ * Completer on the JDBC datasources name (JNDI or OSGi service property).
+ */
+@Service
+public class DataSourceFactoryNamesCompleter implements Completer {
+
+    @Reference
+    private JdbcService jdbcService;
+
+    @Override
+    public int complete(Session session, CommandLine commandLine, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        try {
+            for (String datasource : jdbcService.factoryNames()) {
+                delegate.getStrings().add(datasource);
+            }
+        } catch (Exception e) {
+            // nothing to do
+        }
+        return delegate.complete(session, commandLine, candidates);
+    }
+
+    public JdbcService getJdbcService() {
+        return jdbcService;
+    }
+
+    public void setJdbcService(JdbcService jdbcService) {
+        this.jdbcService = jdbcService;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DeleteCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DeleteCommand.java
new file mode 100644
index 0000000..afa025d
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/DeleteCommand.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.jdbc.command.ds;
+
+import org.apache.karaf.jdbc.command.JdbcCommandSupport;
+import org.apache.karaf.jdbc.command.completers.DataSourcesFileNameCompleter;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "jdbc", name = "ds-delete", description = "Delete a JDBC datasource")
+@Service
+public class DeleteCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "name", description = "The JDBC datasource name (the one used at creation time)", required = true, multiValued = false)
+    @Completion(DataSourcesFileNameCompleter.class)
+    String name;
+
+    @Override
+    public Object execute() throws Exception {
+        this.getJdbcService().delete(name);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/InfoCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/InfoCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/InfoCommand.java
new file mode 100644
index 0000000..0ab22c5
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/InfoCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.jdbc.command.ds;
+
+import org.apache.karaf.jdbc.command.JdbcCommandSupport;
+import org.apache.karaf.jdbc.command.completers.DataSourcesNameCompleter;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "ds-info", description = "Display details about a JDBC datasource")
+@Service
+public class InfoCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "datasource", description = "The JDBC datasource name", required = true, multiValued = false)
+    @Completion(DataSourcesNameCompleter.class)
+    String datasource;
+
+    @Override
+    public Object execute() throws Exception {
+        ShellTable table = new ShellTable();
+
+        table.column("Property");
+        table.column("Value");
+
+        Map<String, String> info = this.getJdbcService().info(datasource);
+        for (String property : info.keySet()) {
+            table.addRow().addContent(property, info.get(property));
+        }
+
+        table.print(System.out);
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/ListCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/ListCommand.java b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/ListCommand.java
new file mode 100644
index 0000000..d665fa5
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/command/ds/ListCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.jdbc.command.ds;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.karaf.jdbc.command.JdbcCommandSupport;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+
+@Command(scope = "jdbc", name = "ds-list", description = "List the JDBC datasources")
+@Service
+public class ListCommand extends JdbcCommandSupport {
+
+    @Override
+    public Object execute() throws Exception {
+        ShellTable table = new ShellTable();
+        table.column("Name");
+        table.column("Product");
+        table.column("Version");
+        table.column("URL");
+        table.column("Status");
+
+        List<String> datasources = this.getJdbcService().datasources();
+        for (String dsName: datasources) {
+            try {
+                Map<String, String> info = this.getJdbcService().info(dsName);
+                table.addRow().addContent(dsName, info.get("db.product"), info.get("db.version"), info.get("url"), "OK");
+            } catch (Exception e) {
+                table.addRow().addContent(dsName, "", "", "", "Error " + e.getMessage());
+            }
+        }
+
+        table.print(System.out);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcConnector.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcConnector.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcConnector.java
index eb1d732..4d176c5 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcConnector.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcConnector.java
@@ -23,6 +23,7 @@ import java.sql.Statement;
 import java.util.Deque;
 import java.util.LinkedList;
 
+import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
 import javax.sql.XAConnection;
 import javax.sql.XADataSource;
@@ -32,12 +33,12 @@ import org.osgi.framework.ServiceReference;
 
 public class JdbcConnector implements Closeable {
 
-    private Object datasource;
+    private CommonDataSource datasource;
     private Connection connection;
     private Deque<AutoCloseable> resources;
 
     public JdbcConnector(final BundleContext bundleContext, final ServiceReference<?> reference) {
-        this.datasource = bundleContext.getService(reference);
+        this.datasource = (CommonDataSource)bundleContext.getService(reference);
         this.resources = new LinkedList<>();
         this.resources.addFirst(new AutoCloseable() {
             @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
index 9f294c3..da33e60 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
@@ -21,6 +21,7 @@ import org.apache.karaf.jdbc.JdbcService;
 
 import javax.management.MBeanException;
 import javax.management.openmbean.*;
+
 import java.util.List;
 import java.util.Map;
 
@@ -63,9 +64,9 @@ public class JdbcMBeanImpl implements JdbcMBean {
     }
 
     @Override
-    public void create(String name, String type, String driver, String version, String url, String user, String password, boolean installBundles) throws MBeanException {
+    public void create(String name, String driverName, String driverClass, String databaseName, String url, String user, String password) throws MBeanException {
         try {
-            jdbcService.create(name, type, driver, version, url, user, password, installBundles);
+            jdbcService.create(name, driverName, driverClass, databaseName, url, user, password);
         } catch (Exception e) {
             throw new MBeanException(null, e.getMessage());
         }
@@ -89,6 +90,7 @@ public class JdbcMBeanImpl implements JdbcMBean {
         }
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
     public TabularData tables(String datasource) throws MBeanException {
         try {
@@ -131,6 +133,7 @@ public class JdbcMBeanImpl implements JdbcMBean {
         }
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
     public TabularData query(String datasource, String query) throws MBeanException {
         try {

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/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 10c7da5..1bd3dd8 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
@@ -16,179 +16,102 @@
  */
 package org.apache.karaf.jdbc.internal;
 
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+
 import org.apache.karaf.jdbc.JdbcService;
-import org.apache.karaf.util.TemplateUtils;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.jdbc.DataSourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.sql.DataSource;
-import javax.sql.XADataSource;
-
-import java.io.*;
-import java.sql.*;
-import java.util.*;
-
 /**
  * Default implementation of the JDBC Service.
  */
 public class JdbcServiceImpl implements JdbcService {
 
-    public static enum TYPES {
-        DB2("wrap:mvn:com.ibm.db2.jdbc/db2jcc/", "9.7", "datasource-db2.xml"),
-        DERBY("mvn:org.apache.derby/derby/", "10.8.2.2", "datasource-derby.xml"),
-        GENERIC(null, null, "datasource-generic.xml"),
-        H2("mvn:com.h2database/h2/", "1.3.163", "datasource-h2.xml"),
-        HSQL("mvn:org.hsqldb/hsqldb/", "2.3.2", "datasource-hsql.xml"),
-        MYSQL("mvn:mysql/mysql-connector-java/", "5.1.18", "datasource-mysql.xml"),
-        MSSQL("wrap:mvn:net.sourceforge.jtds/jtds/", "1.2.4", "datasource-mssql.xml"),
-        ORACLE("wrap:mvn:ojdbc/ojdbc/", "11.2.0.2.0", "datasource-oracle.xml"),
-        POSTGRES("wrap:mvn:postgresql/postgresql/", "9.1-901.jdbc4", "datasource-postgres.xml");
-
-        private final String bundleUrl;
-        private final String defaultVersion;
-        private final String templateFile;
+    private static final Logger LOGGER = LoggerFactory.getLogger(JdbcServiceImpl.class);
 
-        TYPES(String bundleUrl, String defaultVersion, String templateFile) {
-            this.bundleUrl = bundleUrl;
-            this.defaultVersion = defaultVersion;
-            this.templateFile = templateFile;
+    private BundleContext bundleContext;
+    private ConfigurationAdmin configAdmin;
+    
+    @Override
+    public void create(String name, String driverName, String driverClass, String databaseName, String url, String user, String password) throws Exception {
+        if (driverName == null && driverClass == null) {
+            throw new IllegalStateException("No driverName or driverClass supplied");
         }
-
-        public void installBundle(BundleContext bundleContext, String version) throws Exception {
-            String location = this.bundleUrl + getWithDefault(version, this.defaultVersion);
-            bundleContext.installBundle(location, null).start();
+        if (datasources().contains(name)) {
+            throw new IllegalArgumentException("There is already a DataSource with the name " + name);
         }
-
-        private String getWithDefault(String st, String defaultSt) {
-            return (st == null)? defaultSt : st;
+        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);
         }
-
-        public void copyDataSourceFile(File outFile, HashMap<String, String> properties) {
-            InputStream is = this.getClass().getResourceAsStream(templateFile);
-            if (is == null) {
-                throw new IllegalArgumentException("Template resource " + templateFile + " doesn't exist");
-            }
-            TemplateUtils.createFromTemplate(outFile, is, properties);
+        if (driverClass != null) {
+            properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, driverClass);
         }
-
-    }
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(JdbcServiceImpl.class);
-
-    private BundleContext bundleContext;
-
-    @Override
-    public void create(String name, String type, String driverClassName, String version, String url, String user, String password, boolean tryToInstallBundles) throws Exception {
-        if (type == null) {
-            throw new IllegalStateException("No database type supplied");
+        if (databaseName != null) {
+            properties.put(DataSourceFactory.JDBC_DATABASE_NAME, databaseName);
         }
-        TYPES dbType = TYPES.valueOf(type.toUpperCase());
-
-        if (tryToInstallBundles) {
-            dbType.installBundle(bundleContext, version);
+        if (url != null) {
+            properties.put(DataSourceFactory.JDBC_URL, url);
         }
-
-        File karafBase = new File(System.getProperty("karaf.base"));
-        File deployFolder = new File(karafBase, "deploy");
-        File outFile = new File(deployFolder, "datasource-" + name + ".xml");
-
-        HashMap<String, String> properties = new HashMap<String, String>();
-        properties.put("name", name);
-        properties.put("driver", driverClassName);
-        properties.put("url", url);
-        properties.put("user", user);
-        properties.put("password", password);
-
-        dbType.copyDataSourceFile(outFile, properties);
+        if (user != null) {
+            properties.put(DataSourceFactory.JDBC_USER, user);
+        }
+        if (password != null) {
+            properties.put(DataSourceFactory.JDBC_PASSWORD, password);
+        }
+        Configuration config = configAdmin.createFactoryConfiguration("org.ops4j.datasource", null);
+        config.update(properties);
     }
 
     @Override
     public void delete(String name) throws Exception {
-        File karafBase = new File(System.getProperty("karaf.base"));
-        File deployFolder = new File(karafBase, "deploy");
-        File datasourceFile = new File(deployFolder, "datasource-" + name + ".xml");
-        if (!datasourceFile.exists()) {
-            throw new IllegalArgumentException("The JDBC datasource file "+ datasourceFile.getPath() + " doesn't exist");
+        String filter = String.format("(%s=%s)", DataSourceFactory.JDBC_DATASOURCE_NAME, name);
+        Configuration[] configs = configAdmin.listConfigurations(filter);
+        for (Configuration config : configs) {
+            config.delete();
         }
-        datasourceFile.delete();
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
     public List<String> datasources() throws Exception {
         List<String> datasources = new ArrayList<>();
-
-        ServiceReference<?>[] references = bundleContext.getServiceReferences((String) null,
-                "(|(" + Constants.OBJECTCLASS + "=" + DataSource.class.getName() + ")("
-                        + Constants.OBJECTCLASS + "=" + XADataSource.class.getName() + "))");
-        if (references != null) {
-            for (ServiceReference reference : references) {
-                if (reference.getProperty("osgi.jndi.service.name") != null) {
-                    datasources.add(reference.getProperty("osgi.jndi.service.name").toString());
-                }
-                if (reference.getProperty("datasource") != null) {
-                    datasources.add(reference.getProperty("datasource").toString());
-                }
-                if (reference.getProperty("name") != null) {
-                    datasources.add(reference.getProperty("name").toString());
-                }
-                datasources.add(reference.getProperty(Constants.SERVICE_ID).toString());
+        Collection<ServiceReference<DataSource>> references = bundleContext.getServiceReferences(DataSource.class, null);
+        if (references == null) {
+            return datasources;
+        }
+        for (ServiceReference reference : references) {
+            String dsName = (String)reference.getProperty(DataSourceFactory.JDBC_DATASOURCE_NAME);
+            if (dsName != null) {
+                datasources.add(dsName);
             }
         }
         return datasources;
     }
 
     @Override
-    public Map<String, Set<String>> aliases() throws Exception {
-        Map<String, Set<String>> aliases = new LinkedHashMap<>();
-
-        ServiceReference<?>[] references = bundleContext.getServiceReferences((String) null,
-                "(|(" + Constants.OBJECTCLASS + "=" + DataSource.class.getName() + ")("
-                        + Constants.OBJECTCLASS + "=" + XADataSource.class.getName() + "))");
-        if (references != null) {
-            List<ServiceReference<?>> refs = Arrays.asList(references);
-            Collections.sort(refs);
-            Collections.reverse(refs);
-            for (ServiceReference<?> reference : refs) {
-                Set<String> names = new LinkedHashSet<>();
-                if (reference.getProperty("osgi.jndi.service.name") != null) {
-                    names.add(reference.getProperty("osgi.jndi.service.name").toString());
-                }
-                if (reference.getProperty("datasource") != null) {
-                    names.add(reference.getProperty("datasource").toString());
-                }
-                if (reference.getProperty("name") != null) {
-                    names.add(reference.getProperty("name").toString());
-                }
-                String id = reference.getProperty(Constants.SERVICE_ID).toString();
-                names.add(id);
-                aliases.put(id, names);
-            }
-        }
-        return aliases;
-    }
-
-    @Override
-    public List<String> datasourceFileNames() throws Exception {
-        File karafBase = new File(System.getProperty("karaf.base"));
-        File deployFolder = new File(karafBase, "deploy");
-
-        String[] datasourceFileNames = deployFolder.list(new FilenameFilter() {
-
-            @Override
-            public boolean accept(File dir, String name) {
-                return name.startsWith("datasource-") && name.endsWith(".xml");
-            }
-        });
-
-        return Arrays.asList(datasourceFileNames);
-    }
-
-    @Override
     public Map<String, List<String>> query(String datasource, String query) throws Exception {
         JdbcConnector jdbcConnector = new JdbcConnector(bundleContext, lookupDataSource(datasource));
         try {
@@ -264,10 +187,6 @@ public class JdbcServiceImpl implements JdbcService {
         }
     }
 
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-
     private ServiceReference<?> lookupDataSource(String name) {
         ServiceReference<?>[] references;
         try {
@@ -298,4 +217,29 @@ public class JdbcServiceImpl implements JdbcService {
         return (rankObj instanceof Integer) ? (Integer) rankObj : 0;
     }
 
+    @Override
+    public List<String> factoryNames() throws Exception {
+        List<String> factories = new ArrayList<>();
+
+        Collection<ServiceReference<DataSourceFactory>> references = bundleContext.getServiceReferences(DataSourceFactory.class, null);
+        if (references == null) {
+            return factories;
+        }
+        for (ServiceReference<DataSourceFactory> reference : references) {
+            String driverName = (String)reference.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_NAME);
+            if (driverName != null) {
+                factories.add(driverName);
+            }
+        }
+
+        return factories;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public void setConfigAdmin(ConfigurationAdmin configAdmin) {
+        this.configAdmin = configAdmin;
+    }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
index 8fe66a7..f05058b 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
@@ -21,14 +21,21 @@ import org.apache.karaf.jdbc.internal.JdbcMBeanImpl;
 import org.apache.karaf.jdbc.internal.JdbcServiceImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
 import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
 import org.apache.karaf.util.tracker.Services;
+import org.osgi.service.cm.ConfigurationAdmin;
 
-@Services(provides = @ProvideService(JdbcService.class))
+@Services(
+    provides = @ProvideService(JdbcService.class),
+    requires = @RequireService(ConfigurationAdmin.class)
+)
 public class Activator extends BaseActivator {
     @Override
     protected void doStart() throws Exception {
+        ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
         JdbcServiceImpl service = new JdbcServiceImpl();
         service.setBundleContext(bundleContext);
+        service.setConfigAdmin(configurationAdmin);
         register(JdbcService.class, service);
 
         JdbcMBeanImpl mbean = new JdbcMBeanImpl();

http://git-wip-us.apache.org/repos/asf/karaf/blob/e3949f57/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f41112f..a9e3b4d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -206,7 +206,7 @@
         <aries.proxy.api.version>1.0.1</aries.proxy.api.version>
         <aries.subsystem.api.version>1.0.0</aries.subsystem.api.version>
         <aries.subsystem.core.version>1.1.0</aries.subsystem.core.version>
-        <aries.transaction.manager.version>1.1.1</aries.transaction.manager.version>
+        <aries.transaction.manager.version>1.1.2-SNAPSHOT</aries.transaction.manager.version>
         <aries.transaction.blueprint.version>1.0.1</aries.transaction.blueprint.version>
         <aries.transaction.jdbc.version>2.0.0</aries.transaction.jdbc.version>
         <aries.util.version>1.1.0</aries.util.version>