db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r632274 - in /db/derby/code/branches/10.3/java: client/org/apache/derby/client/ClientDataSourceFactory.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
Date Fri, 29 Feb 2008 09:45:28 GMT
Author: kristwaa
Date: Fri Feb 29 01:45:23 2008
New Revision: 632274

URL: http://svn.apache.org/viewvc?rev=632274&view=rev
Log:
DERBY-2559: recreating a datasource using javax.naming.Reference from a ClientDataSource40
fails.
Merged fixes from trunk (10.4): r617492 and r628647.

Modified:
    db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java

Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java?rev=632274&r1=632273&r2=632274&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java
(original)
+++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/ClientDataSourceFactory.java
Fri Feb 29 01:45:23 2008
@@ -26,11 +26,6 @@
 
 import javax.naming.RefAddr;
 import javax.naming.Reference;
-import org.apache.derby.jdbc.ClientBaseDataSource;
-
-import org.apache.derby.jdbc.ClientConnectionPoolDataSource;
-import org.apache.derby.jdbc.ClientDataSource;
-import org.apache.derby.jdbc.ClientXADataSource;
 
 /**
  * The data source factory currrently for ClientDataSource only. This factory will support
XA and pooling-enabled data
@@ -78,23 +73,22 @@
                                     javax.naming.Name name,
                                     javax.naming.Context nameContext,
                                     java.util.Hashtable environment) throws java.lang.Exception
{
-        javax.naming.Reference ref = (javax.naming.Reference) refObj;
-
-        // Create the proper data source object shell.
-        ClientBaseDataSource ds = null;
-        if (ref.getClassName().equals(ClientDataSource.className__)) {
-            ds = new ClientDataSource();
-        } else if (ref.getClassName().equals(ClientXADataSource.className__)) {
-            ds = new ClientXADataSource();
-        } else if (ref.getClassName().equals(ClientConnectionPoolDataSource.className__))
{
-            ds = new ClientConnectionPoolDataSource();
-        } else {
-            return null;
+        Object ds = null;
+        if (refObj instanceof javax.naming.Reference) {
+            javax.naming.Reference ref = (javax.naming.Reference) refObj;
+
+            // See if this object belongs to Derby.
+            String className = ref.getClassName();
+            if (className != null &&
+                    className.startsWith("org.apache.derby.jdbc.Client")) {
+                // Create the proper data source object shell.
+                ds = Class.forName(className).newInstance();
+
+                // Fill in the data source object shell with values from the
+                // jndi reference.
+                ClientDataSourceFactory.setBeanProperties(ds, ref);
+            }
         }
-
-        // Fill in the data source object shell with values from the jndi reference.
-        ClientDataSourceFactory.setBeanProperties(ds, ref);
-
         return ds;
     }
     

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java?rev=632274&r1=632273&r2=632274&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceReferenceTest.java
Fri Feb 29 01:45:23 2008
@@ -189,11 +189,6 @@
         Object recreatedDS = 
             factory.getObjectInstance(dsAsReference, null, null, null);
         
-        // DERBY-2559 - with jdk16, this recreatedDS will be null.
-        // bailing out
-        if (JDBC.vmSupportsJDBC4())
-            return;
-        
         println(" empty DataSource recreated using Reference as " +
             recreatedDS.getClass().getName());
         // empty DataSource recreated using Reference should not be 
@@ -387,4 +382,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}



Mime
View raw message