You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2006/05/23 23:11:43 UTC

svn commit: r409007 - in /db/derby/code/trunk/java/client/org/apache/derby/jdbc: ClientConnectionPoolDataSource.java ClientConnectionPoolDataSource40.java ClientXADataSource.java ClientXADataSource40.java

Author: rhillegas
Date: Tue May 23 14:11:42 2006
New Revision: 409007

URL: http://svn.apache.org/viewvc?rev=409007&view=rev
Log:
DERBY-1340: Anurag's derby-1340.diff, which reverts the refactoring of the client api committed as part of DERBY-1246.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=409007&r1=409006&r2=409007&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java Tue May 23 14:11:42 2006
@@ -40,7 +40,7 @@
  * <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
  * </UL>
  */
-public class ClientConnectionPoolDataSource extends ClientBaseDataSource 
+public class ClientConnectionPoolDataSource extends ClientDataSource 
                                            implements ConnectionPoolDataSource {
     private static final long serialVersionUID = -539234282156481377L;
     public static final String className__ = "org.apache.derby.jdbc.ClientConnectionPoolDataSource";

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java?rev=409007&r1=409006&r2=409007&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource40.java Tue May 23 14:11:42 2006
@@ -21,10 +21,12 @@
 package org.apache.derby.jdbc;
 
 import java.sql.BaseQuery;
+import java.sql.QueryObjectFactory;
 import java.sql.QueryObjectGenerator;
 import java.sql.SQLException;
-import javax.sql.ConnectionPoolDataSource;
-import org.apache.derby.client.am.SQLExceptionFactory;
+import org.apache.derby.client.am.ClientMessageId;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.shared.common.reference.SQLState;
 
 /**
  * ClientConnectionPoolDataSource40 is a factory for PooledConnection objects.
@@ -54,5 +56,49 @@
      */
     public QueryObjectGenerator getQueryObjectGenerator() throws SQLException {
         return null;
+    }    
+    
+    /**
+     * This method forwards all the calls to default query object provided by 
+     * the jdk.
+     * @param ifc interface to generated concreate class
+     * @return concreat class generated by default qury object generator
+     */
+    public <T extends BaseQuery> T createQueryObject(Class<T> ifc) 
+                                                    throws SQLException {
+        return QueryObjectFactory.createDefaultQueryObject (ifc, this);
+    }   
+    
+    /**
+     * Returns false unless <code>interfaces</code> is implemented 
+     * 
+     * @param  interfaces             a Class defining an interface.
+     * @return true                   if this implements the interface or 
+     *                                directly or indirectly wraps an object 
+     *                                that does.
+     * @throws java.sql.SQLException  if an error occurs while determining 
+     *                                whether this is a wrapper for an object 
+     *                                with the given interface.
+     */
+    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+        return interfaces.isInstance(this);
+    }
+    
+    /**
+     * Returns <code>this</code> if this class implements the interface
+     *
+     * @param  interfaces a Class defining an interface
+     * @return an object that implements the interface
+     * @throws java.sql.SQLExption if no object if found that implements the 
+     * interface
+     */
+    public <T> T unwrap(java.lang.Class<T> interfaces)
+                                   throws SQLException {
+        try { 
+            return interfaces.cast(this);
+        } catch (ClassCastException cce) {
+            throw new SqlException(null,new ClientMessageId(
+                    SQLState.UNABLE_TO_UNWRAP), interfaces).getSQLException();
+        }
     }    
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java?rev=409007&r1=409006&r2=409007&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java Tue May 23 14:11:42 2006
@@ -49,7 +49,7 @@
  *
  * <P>See ClientDataSource for DataSource properties.</p>
  */
-public class ClientXADataSource extends ClientBaseDataSource implements XADataSource {
+public class ClientXADataSource extends ClientDataSource implements XADataSource {
     public static final String className__ = "org.apache.derby.jdbc.ClientXADataSource";
 
     // following serialVersionUID was generated by the JDK's serialver program

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java?rev=409007&r1=409006&r2=409007&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource40.java Tue May 23 14:11:42 2006
@@ -21,14 +21,15 @@
 package org.apache.derby.jdbc;
 
 import java.sql.BaseQuery;
+import java.sql.QueryObjectFactory;
 import java.sql.QueryObjectGenerator;
 import java.sql.SQLException;
-import javax.sql.DataSource;
 import javax.sql.XAConnection;
 import org.apache.derby.client.ClientXAConnection40;
-import org.apache.derby.client.am.SQLExceptionFactory;
+import org.apache.derby.client.am.ClientMessageId;
 import org.apache.derby.client.am.SqlException;
 import org.apache.derby.client.net.NetLogWriter;
+import org.apache.derby.shared.common.reference.SQLState;
 
 /**
  * <p>
@@ -78,5 +79,49 @@
         } catch ( SqlException se ) {
             throw se.getSQLException();
         }
-    }    
+    }
+    
+    /**
+     * This method forwards all the calls to default query object provided by 
+     * the jdk.
+     * @param ifc interface to generated concreate class
+     * @return concreat class generated by default qury object generator
+     */
+    public <T extends BaseQuery> T createQueryObject(Class<T> ifc) 
+                                                    throws SQLException {
+        return QueryObjectFactory.createDefaultQueryObject (ifc, this);
+    }   
+    
+    /**
+     * Returns false unless <code>interfaces</code> is implemented 
+     * 
+     * @param  interfaces             a Class defining an interface.
+     * @return true                   if this implements the interface or 
+     *                                directly or indirectly wraps an object 
+     *                                that does.
+     * @throws java.sql.SQLException  if an error occurs while determining 
+     *                                whether this is a wrapper for an object 
+     *                                with the given interface.
+     */
+    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+        return interfaces.isInstance(this);
+    }
+    
+    /**
+     * Returns <code>this</code> if this class implements the interface
+     *
+     * @param  interfaces a Class defining an interface
+     * @return an object that implements the interface
+     * @throws java.sql.SQLExption if no object if found that implements the 
+     * interface
+     */
+    public <T> T unwrap(java.lang.Class<T> interfaces)
+                                   throws SQLException {
+        try { 
+            return interfaces.cast(this);
+        } catch (ClassCastException cce) {
+            throw new SqlException(null,new ClientMessageId(
+                    SQLState.UNABLE_TO_UNWRAP), interfaces).getSQLException();
+        }
+    }
 }