You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2008/11/21 22:06:45 UTC

svn commit: r719711 - /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

Author: fhanik
Date: Fri Nov 21 13:06:44 2008
New Revision: 719711

URL: http://svn.apache.org/viewvc?rev=719711&view=rev
Log:
add async call template, not sure how it will work, but I will know soon
make sure that timewait is a positive value, 0 being the lowest

Modified:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java

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=719711&r1=719710&r2=719711&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 Fri Nov 21 13:06:44 2008
@@ -27,6 +27,8 @@
 import java.util.Queue;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.juli.logging.Log;
@@ -109,6 +111,11 @@
         init(prop);
     }
 
+
+    public Future<Connection> getConnectionAsync() throws SQLException {
+        return null;
+    }
+    
     /**
      * Borrows a connection from the pool
      * @return Connection - a java.sql.Connection reflection proxy, wrapping the underlying object.
@@ -117,6 +124,10 @@
     public Connection getConnection() throws SQLException {
         //check out a connection
         PooledConnection con = (PooledConnection)borrowConnection();
+        return setupConnection(con);
+    }
+
+    protected Connection setupConnection(PooledConnection con) throws SQLException {
         JdbcInterceptor handler = con.getHandler();
         if (handler==null) {
             //build the proxy handler
@@ -164,8 +175,9 @@
             s.initCause(x);
             throw s;
         }
-    }
 
+    }
+    
     /**
      * Returns the name of this pool
      * @return String
@@ -394,7 +406,7 @@
 
             //calculate wait time for this iteration
             long maxWait = (getPoolProperties().getMaxWait()<=0)?Long.MAX_VALUE:getPoolProperties().getMaxWait();
-            long timetowait = Math.max(1, maxWait - (System.currentTimeMillis() - now));
+            long timetowait = Math.max(0, maxWait - (System.currentTimeMillis() - now));
             try {
                 //retrieve an existing connection
                 con = idle.poll(timetowait, TimeUnit.MILLISECONDS);



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