Permalink
Browse files

[KARAF-2549] Add new JDBC enterprise feature

git-svn-id: https://svn.apache.org/repos/asf/karaf/trunk@1551219 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent e68ceb0 commit b9a1ff7cc33e10ea30d68ca110948b829b1e49e4 @jbonofre jbonofre committed Dec 16, 2013
Showing with 1,978 additions and 3 deletions.
  1. +9 −0 assemblies/features/enterprise/src/main/feature/feature.xml
  2. +71 −0 jdbc/command/NOTICE
  3. +90 −0 jdbc/command/pom.xml
  4. +55 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
  5. +47 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
  6. +33 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
  7. +36 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/ExecuteCommand.java
  8. +47 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
  9. +36 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/JdbcCommandSupport.java
  10. +58 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/QueryCommand.java
  11. +55 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/TablesCommand.java
  12. +53 −0 jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesCompleter.java
  13. +84 −0 jdbc/command/src/main/resources/OSGI-INF/blueprint/jdbc-command.xml
  14. +26 −0 jdbc/command/src/main/resources/OSGI-INF/bundle.info
  15. +71 −0 jdbc/core/NOTICE
  16. +82 −0 jdbc/core/pom.xml
  17. +96 −0 jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
  18. +88 −0 jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcService.java
  19. +168 −0 jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
  20. +309 −0 jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
  21. +41 −0 jdbc/core/src/main/resources/OSGI-INF/blueprint/jdbc-core.xml
  22. +18 −0 jdbc/core/src/main/resources/OSGI-INF/bundle.info
  23. +16 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-db2.xml
  24. +23 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-derby.xml
  25. +17 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml
  26. +15 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-h2.xml
  27. +15 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-hsql.xml
  28. +15 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mysql.xml
  29. +15 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-oracle.xml
  30. +18 −0 jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-postgres.xml
  31. +41 −0 jdbc/pom.xml
  32. +2 −2 manual/src/main/webapp/_navigation.conf
  33. +2 −0 manual/src/main/webapp/manual.conf
  34. +1 −0 manual/src/main/webapp/users-guide/enterprise.conf
  35. +1 −1 manual/src/main/webapp/users-guide/index.conf
  36. +212 −0 manual/src/main/webapp/users-guide/jdbc.conf
  37. +12 −0 pom.xml
@@ -59,6 +59,15 @@
<bundle>mvn:org.apache.karaf.jndi/org.apache.karaf.jndi.command/${project.version}</bundle>
</feature>
+ <feature name='jdbc' description='JDBC service and commands' version='${project.version}' resolver='(obr)'>
+ <details>JDBC support providing service, commands, and MBean.</details>
+ <feature>transaction</feature>
+ <bundle>mvn:commons-pool/commons-pool/1.6</bundle>
+ <bundle>mvn:commons-dbcp/commons-dbcp/1.4</bundle>
+ <bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.core/${project.version}</bundle>
+ <bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.command/${project.version}</bundle>
+ </feature>
+
<feature name='application-without-isolation' description='Provide EBA archive support' version='${aries.application.version}'>
<details>Support of the Aries EBA archives</details>
<!-- pre-requisites-->
View
@@ -0,0 +1,71 @@
+Apache Karaf
+Copyright 2010-2013 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+OW2 (http://www.ow2.org/).
+Licensed under the BSD License.
+
+This product includes software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Eclipse Foundation (http://www.eclipse.org/).
+Licensed under the EPL.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+AOP Alliance (http://aopalliance.sourceforge.net/).
+Licensed under the Public Domain.
+
+This product uses software developed at
+Tanuki Software (http://www.tanukisoftware.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Jasypt (http://jasypt.sourceforge.net/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product uses software developed at
+SpringSource (http://www.springsource.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0
+- BSD License
+- EPL License
+- MIT License
View
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.jdbc</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.karaf.jdbc.command</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Karaf :: JDBC :: Command</name>
+ <description>This bundle provides shell commands to manipulate the JDBC service</description>
+
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.jdbc</groupId>
+ <artifactId>org.apache.karaf.jdbc.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.table</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>!*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
@@ -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;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+
+@Command(scope = "jdbc", name = "create", description = "Create a JDBC datasource")
+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)", required = false, multiValued = false)
+ 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;
+
+ public Object doExecute() throws Exception {
+ this.getJdbcService().create(name, type, driver, version, url, username, password, installBundles);
+ return null;
+ }
+
+}
@@ -0,0 +1,47 @@
+/*
+ * 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.commands.Command;
+import org.apache.karaf.shell.table.ShellTable;
+
+import java.util.List;
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "datasources", description = "List the JDBC datasources")
+public class DataSourcesCommand extends JdbcCommandSupport {
+
+ public Object doExecute() throws Exception {
+ ShellTable table = new ShellTable();
+
+ table.column("Name");
+ table.column("Product");
+ table.column("Version");
+ table.column("URL");
+
+ List<String> datasources = this.getJdbcService().datasources();
+ for (String datasource : datasources) {
+ Map<String, String> info = this.getJdbcService().info(datasource);
+ table.addRow().addContent(datasource, info.get("db.product"), info.get("db.version"), info.get("url"));
+ }
+
+ table.print(System.out);
+
+ return null;
+ }
+
+}
@@ -0,0 +1,33 @@
+/*
+ * 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.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+
+@Command(scope = "jdbc", name = "delete", description = "Delete a JDBC datasource")
+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)
+ String name;
+
+ public Object doExecute() throws Exception {
+ this.getJdbcService().delete(name);
+ return null;
+ }
+
+}
@@ -0,0 +1,36 @@
+/*
+ * 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.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+
+@Command(scope = "jdbc", name = "execute", description = "Execute a SQL command on a given JDBC datasource")
+public class ExecuteCommand extends JdbcCommandSupport {
+
+ @Argument(index = 0, name = "datasource", description = "The JDBC datasource", required = true, multiValued = false)
+ String datasource;
+
+ @Argument(index = 1, name = "command", description = "The SQL command to execute", required = true, multiValued = false)
+ String command;
+
+ public Object doExecute() throws Exception {
+ this.getJdbcService().execute(datasource, command);
+ return null;
+ }
+
+}
Oops, something went wrong.

0 comments on commit b9a1ff7

Please sign in to comment.