[
https://issues.apache.org/jira/browse/KARAF-3976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16292270#comment-16292270
]
ASF GitHub Bot commented on KARAF-3976:
---------------------------------------
jbonofre closed pull request #431: [KARAF-3976] Able to use "old style"
datasource names/properties
URL: https://github.com/apache/karaf/pull/431
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 aa367c9ece..896bce853e 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
@@ -93,16 +93,26 @@ public void delete(String name) throws Exception {
@Override
public List<String> datasources() throws Exception {
List<String> datasources = new ArrayList<>();
- 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);
+
+ 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());
+ } else if (reference.getProperty("datasource") != null) {
+
datasources.add(reference.getProperty("datasource").toString());
+ } else if (reference.getProperty("name") != null) {
+ datasources.add(reference.getProperty("name").toString());
+ } else if
(reference.getProperty(DataSourceFactory.JDBC_DATASOURCE_NAME) != null) {
+
datasources.add(reference.getProperty(DataSourceFactory.JDBC_DATASOURCE_NAME).toString());
+ } else {
+
datasources.add(reference.getProperty(Constants.SERVICE_ID).toString());
+ }
}
}
+
return datasources;
}
diff --git a/manual/src/main/asciidoc/user-guide/jdbc.adoc
b/manual/src/main/asciidoc/user-guide/jdbc.adoc
index 8324b330af..8ed2562488 100644
--- a/manual/src/main/asciidoc/user-guide/jdbc.adoc
+++ b/manual/src/main/asciidoc/user-guide/jdbc.adoc
@@ -19,12 +19,11 @@ The Apache Karaf DataSources (JDBC) is an optional
enterprise feature.
You have to install the following features first:
----
-karaf@root()> feature:repo-add pax-jdbc
-karaf@root()> feature:install pax-jdbc
-karaf@root()> feature:install pax-jdbc-config
karaf@root()> feature:install jdbc
----
+NB: `jdbc` feature automatically installs the `pax-jdbc-*` core features.
+
Pax JDBC provides ready to use adapters for different databases:
* pax-jdbc-derby
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Broken compatibility with 3.x jdbc DataSources
> ----------------------------------------------
>
> Key: KARAF-3976
> URL: https://issues.apache.org/jira/browse/KARAF-3976
> Project: Karaf
> Issue Type: Bug
> Components: karaf-jdbc
> Affects Versions: 4.0.1
> Reporter: Sergey
> Assignee: Jean-Baptiste Onofré
> Fix For: 4.0.11, 4.1.4, 4.2.0
>
>
> 1st of all, current documentaion is wrong, because command names was changed
> to jdbc:ds-info, for example, but
> http://karaf.apache.org/manual/latest/users-guide/jdbc.html still contains
> jdbc:info command names.
> Most important compatibility breaking change was another one: in karaf 3.x I
> was able to deploy DataSource using spring-dm xml or blueprint, and it was
> registered as a service and in jndi, and was listed using jdbc:datasources
> command. Right now no datasources are listed.
> {code}
> karaf@root()> jndi:names
> JNDI Name | Class Name
> ------------------------------------------------------------------------------------------
> osgi:service/jdbc/zeusDataSource |
> net.sourceforge.jtds.jdbcx.JtdsDataSource
> osgi:service/jdbc/arenaDS |
> net.sourceforge.jtds.jdbcx.JtdsDataSource
> osgi:service/jdbc/tomsDS |
> net.sourceforge.jtds.jdbcx.JtdsDataSource
> osgi:service/jdbc/cofDS |
> com.sybase.jdbc3.jdbc.SybDataSource
> osgi:service/jdbc/fidbDataSource |
> net.sourceforge.jtds.jdbcx.JtdsDataSource
> osgi:service/jdbc/murexDS |
> com.sybase.jdbc3.jdbc.SybDataSource
> osgi:service/jdbc/gpDataSource |
> org.postgresql.ds.PGPoolingDataSource
> karaf@root()> jdbc:ds-info jdbc/fidbDataSource
> Property | Value
> ---------------------------------------------------------------------
> driver.version | 1.2.2
> db.version | 10.50.4000
> db.product | Microsoft SQL Server
> url | jdbc:jtds:sqlserver:
> driver.name | jTDS Type 4 JDBC Driver for MS SQL Server and Sybase
> username | ...
> karaf@root()> jdbc:ds-list
> Name | Product | Version | URL | Status
> ---------------------------------------
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)