tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r801270 - in /tomcat/trunk/modules/jdbc-pool: build.properties.default java/org/apache/tomcat/jdbc/pool/ConnectionPool.java java/org/apache/tomcat/jdbc/pool/DataSource.java java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java sign.sh
Date Wed, 05 Aug 2009 15:42:55 GMT
Author: fhanik
Date: Wed Aug  5 15:42:55 2009
New Revision: 801270

URL: http://svn.apache.org/viewvc?rev=801270&view=rev
Log:
Add in support for XA drivers and connections. 
Update version

Modified:
    tomcat/trunk/modules/jdbc-pool/build.properties.default
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSource.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
    tomcat/trunk/modules/jdbc-pool/sign.sh

Modified: tomcat/trunk/modules/jdbc-pool/build.properties.default
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/build.properties.default?rev=801270&r1=801269&r2=801270&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/build.properties.default (original)
+++ tomcat/trunk/modules/jdbc-pool/build.properties.default Wed Aug  5 15:42:55 2009
@@ -27,7 +27,7 @@
 # ----- Vesion Control Flags -----
 version.major=1
 version.minor=0
-version.build=7
+version.build=8
 version.patch=
 version.suffix=
 

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=801270&r1=801269&r2=801270&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java Wed
Aug  5 15:42:55 2009
@@ -35,6 +35,8 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import javax.sql.XAConnection;
+
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -275,7 +277,7 @@
         }
 
         try {
-            getProxyConstructor();
+            getProxyConstructor(con.getConnection() instanceof XAConnection);
             //create the proxy
             //TODO possible optimization, keep track if this connection was returned properly,
and don't generate a new facade
             Connection connection = (Connection)proxyClassConstructor.newInstance(new Object[]
{ handler });
@@ -295,10 +297,12 @@
      * @return constructor used to instantiate the wrapper object
      * @throws NoSuchMethodException
      */
-    public Constructor<?> getProxyConstructor() throws NoSuchMethodException {
+    public Constructor<?> getProxyConstructor(boolean xa) throws NoSuchMethodException
{
         //cache the constructor
         if (proxyClassConstructor == null ) {
-            Class<?> proxyClass = Proxy.getProxyClass(ConnectionPool.class.getClassLoader(),
new Class[] {java.sql.Connection.class,javax.sql.PooledConnection.class});
+            Class<?> proxyClass = xa ?
+                Proxy.getProxyClass(ConnectionPool.class.getClassLoader(), new Class[] {java.sql.Connection.class,javax.sql.PooledConnection.class,
javax.sql.XAConnection.class}) :
+                Proxy.getProxyClass(ConnectionPool.class.getClassLoader(), new Class[] {java.sql.Connection.class,javax.sql.PooledConnection.class});
             proxyClassConstructor = proxyClass.getConstructor(new Class[] { InvocationHandler.class
});
         }
         return proxyClassConstructor;

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSource.java?rev=801270&r1=801269&r2=801270&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSource.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSource.java Wed Aug
 5 15:42:55 2009
@@ -24,6 +24,7 @@
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
+import javax.sql.XADataSource;
 
 
 /**
@@ -33,7 +34,7 @@
  * @author Filip Hanik
  * @version 1.0
  */
-public class DataSource extends DataSourceProxy implements MBeanRegistration,javax.sql.DataSource,
org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean {
+public class DataSource extends DataSourceProxy implements MBeanRegistration,javax.sql.DataSource,XADataSource,
org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean {
 
     /**
      * Constructor for reflection only. A default set of pool properties will be created.

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=801270&r1=801269&r2=801270&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Wed
Aug  5 15:42:55 2009
@@ -19,10 +19,13 @@
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.concurrent.Future;
 
+import javax.sql.XAConnection;
+
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
@@ -114,6 +117,33 @@
             return createPool().getConnectionAsync();
         return pool.getConnectionAsync();
     }
+    
+    /**
+     * {@link javax.sql.XADataSource#getXAConnection()} 
+     */
+    public XAConnection getXAConnection() throws SQLException {
+        Connection con = getConnection();
+        if (con instanceof XAConnection) {
+            return (XAConnection)con;
+        } else {
+            try {con.close();} catch (Exception ignore){}
+            throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
+        }
+    }
+    
+    /**
+     * {@link javax.sql.XADataSource#getXAConnection(String, String)} 
+     */
+    public XAConnection getXAConnection(String username, String password) throws SQLException
{
+        Connection con = getConnection(username, password);
+        if (con instanceof XAConnection) {
+            return (XAConnection)con;
+        } else {
+            try {con.close();} catch (Exception ignore){}
+            throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
+        }
+    }
+
 
     /**
      * {@link javax.sql.DataSource#getConnection()}

Modified: tomcat/trunk/modules/jdbc-pool/sign.sh
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/sign.sh?rev=801270&r1=801269&r2=801270&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/sign.sh (original)
+++ tomcat/trunk/modules/jdbc-pool/sign.sh Wed Aug  5 15:42:55 2009
@@ -15,7 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-VERSION=v1.0.7
+VERSION=v1.0.8
 for i in $(find output/release/$VERSION -name "*.zip" -o -name "*.tar.gz"); do
   echo Signing $i
   echo $1|gpg --passphrase-fd 0 -a -b $i



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message