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 2009/07/14 00:18:18 UTC

svn commit: r793732 [1/2] - in /tomcat/trunk/modules/jdbc-pool: ./ doc/ java/org/apache/tomcat/jdbc/pool/ java/org/apache/tomcat/jdbc/pool/interceptor/ java/org/apache/tomcat/jdbc/pool/jmx/ test/org/apache/tomcat/jdbc/test/

Author: fhanik
Date: Mon Jul 13 22:18:17 2009
New Revision: 793732

URL: http://svn.apache.org/viewvc?rev=793732&view=rev
Log:
Add tons of javadoc
Remove the finalizers, they behave way differently in the new JDK, so let the programmer be responsible for closures


Modified:
    tomcat/trunk/modules/jdbc-pool/.classpath
    tomcat/trunk/modules/jdbc-pool/build.properties.default
    tomcat/trunk/modules/jdbc-pool/build.xml
    tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
    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/DataSourceFactory.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CreateTestTable.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOAsyncExample.java
    tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java

Modified: tomcat/trunk/modules/jdbc-pool/.classpath
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/.classpath?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/.classpath (original)
+++ tomcat/trunk/modules/jdbc-pool/.classpath Mon Jul 13 22:18:17 2009
@@ -8,6 +8,6 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="includes/mysql-connector-java-5.1.7/mysql-connector-java-5.1.7-bin.jar"/>
 	<classpathentry kind="lib" path="includes/db-derby-10.5.1.1-bin/lib/derby.jar"/>
-	<classpathentry kind="lib" path="includes/h2/bin/h2-1.1.114.jar"/>
+	<classpathentry kind="lib" path="includes/h2/bin/h2-1.1.115.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: tomcat/trunk/modules/jdbc-pool/build.properties.default
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/build.properties.default?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/build.properties.default (original)
+++ tomcat/trunk/modules/jdbc-pool/build.properties.default Mon Jul 13 22:18:17 2009
@@ -48,7 +48,7 @@
 testdb.password=password
 
 # H2
-testdb.url=jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE
+testdb.url=jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=TRUE;LOCK_TIMEOUT=50000;DEFAULT_LOCK_TIMEOUT=50000
 testdb.driverClassName=org.h2.Driver
 testdb.validationQuery=SELECT 1
 
@@ -97,5 +97,5 @@
 derby.jar=${derby.home}/lib/derby.jar
 
 h2.home=${base.path}/h2
-h2.loc=http://www.h2database.com/h2-2009-06-01.zip
-h2.jar=${h2.home}/bin/h2-1.1.114.jar
+h2.loc=http://www.h2database.com/h2-2009-06-27.zip
+h2.jar=${h2.home}/bin/h2-1.1.115.jar

Modified: tomcat/trunk/modules/jdbc-pool/build.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/build.xml?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/build.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/build.xml Mon Jul 13 22:18:17 2009
@@ -86,6 +86,7 @@
   </target>
 
   <target name="javadoc" depends="prepare">
+  
      <xslt basedir="${tomcat.pool}/doc"
           destdir="${basedir}/java/org/apache/tomcat/jdbc/pool"
           extension=".html"
@@ -395,6 +396,7 @@
   <target name="test" depends="build,build-test">
     <echo/>
     <echo>Creating test table for test purposes.</echo>
+ 
     <junit printsummary="withOutAndErr" showoutput="on">
       <syspropertyset refid="testdb"/>
       <classpath refid="tomcat.jdbc.classpath"/>
@@ -405,7 +407,7 @@
         </fileset>
       </batchtest>
     </junit>
-
+ 
     <echo/>
     <echo>Performance and fairness tests.</echo>
     <junit printsummary="withOutAndErr" showoutput="on">
@@ -445,5 +447,26 @@
   <target name="simplebuild" depends="build">
   </target>
 
+  <target name="onetest" depends="build,build-test">
+    
+    <echo>Testing:${test}</echo>
+    <junit printsummary="yes">
+      <syspropertyset refid="testdb"/>
+      <formatter type="plain"/>
+      <classpath refid="tomcat.jdbc.classpath"/>
+      <classpath refid="test.classpath"/>
+      <batchtest fork="yes" todir="${tomcat.testclasses}">
+        <fileset dir="${basedir}/test">
+          <include name="org/apache/tomcat/jdbc/test/*${test}*.java"/>
+          <exclude name="**/CreateTestTable*"/>
+          <exclude name="**/DefaultTestCase*"/>
+          <exclude name="**/CheckOutThread*"/>
+          <exclude name="**/Fairness*"/>
+        </fileset>
+      </batchtest>
+    </junit>
+
+  </target>
+    
 </project>
 

Modified: tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml (original)
+++ tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml Mon Jul 13 22:18:17 2009
@@ -227,8 +227,10 @@
 
     <attribute name="testOnBorrow" required="false">
       <p>(boolean) The indication of whether objects will be validated before being borrowed from the pool. 
-         If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
-         NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
+         If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. 
+         NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. 
+         Default value is false
+         In order to have a more efficient validation, see <code>validationInterval</code>
          Default value is <code>false</code>
       </p>
     </attribute>
@@ -275,7 +277,8 @@
 
     <attribute name="accessToUnderlyingConnectionAllowed" required="false">
       <p>(boolean) Property not used. Access can be achieved by calling <code>unwrap</code> on the pooled connection.
-         see <code>javax.sql.DataSource</code> interface, or call <code>getConnection</code> through reflection.</p>
+         see <code>javax.sql.DataSource</code> interface, or call <code>getConnection</code> through reflection or
+          or cast the object as <code>javax.sql.PooledConnection</code></p>
     </attribute>
 
     <attribute name="removeAbandoned" required="false">
@@ -415,8 +418,9 @@
     <p>Abstract base class for all interceptors, can not be instantiated.</p>
     <attributes>
       <attribute name="useEquals" required="false">
-        <p>(String as boolean) A custom query to be run when a connection is first created. 
-           The default value is <code>false</code>.
+        <p>(String as boolean) Set to true if you wish the interceptor class to use <code>String.equals</code> instead of 
+         <code>==</code> when comparing method names. This property does not apply to added interceptors as those are configured individually.
+         The default value is <code>false</code>.
         </p>
       </attribute>
     </attributes>  

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=793732&r1=793731&r2=793732&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 Mon Jul 13 22:18:17 2009
@@ -75,7 +75,7 @@
      * All the information about the connection pool
      * These are the properties the pool got instantiated with
      */
-    private PoolProperties poolProperties;
+    private PoolConfiguration poolProperties;
 
     /**
      * Contains all the connections that are in use
@@ -129,7 +129,7 @@
      * @param prop PoolProperties - all the properties for this connection pool
      * @throws SQLException
      */
-    public ConnectionPool(PoolProperties prop) throws SQLException {
+    public ConnectionPool(PoolConfiguration prop) throws SQLException {
         //setup quick access variables and pools
         init(prop);
     }
@@ -188,7 +188,7 @@
      * @return PoolProperties
      * 
      */
-    public PoolProperties getPoolProperties() {
+    public PoolConfiguration getPoolProperties() {
         return this.poolProperties;
     }
 
@@ -312,12 +312,12 @@
      */
     @Override
     protected void finalize() throws Throwable {
-        Runnable closer = new Runnable() {
-            public void run() {
-                close(true);
-            }
-        };
-        this.cancellator.execute(closer);
+//        Runnable closer = new Runnable() {
+//            public void run() {
+//                close(true);
+//            }
+//        };
+//        this.cancellator.execute(closer);
     }
 
     /**
@@ -373,7 +373,7 @@
      * @param properties PoolProperties - properties used to initialize the pool with
      * @throws SQLException if initialization fails
      */
-    protected void init(PoolProperties properties) throws SQLException {
+    protected void init(PoolConfiguration properties) throws SQLException {
         poolProperties = properties;
         //make space for 10 extra in case we flow over a bit
         busy = new ArrayBlockingQueue<PooledConnection>(properties.getMaxActive(),false);

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=793732&r1=793731&r2=793732&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 Mon Jul 13 22:18:17 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.tomcat.jdbc.pool;
 
-import java.io.PrintWriter;
 import java.lang.management.ManagementFactory;
 import java.sql.SQLException;
 import java.util.Hashtable;
@@ -28,27 +27,35 @@
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
-import org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean;
+import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
 
 
 /**
  * A DataSource that can be instantiated through IoC and implements the DataSource interface
- * since the DataSourceProxy is used as a generic proxy
+ * since the DataSourceProxy is used as a generic proxy.
+ * The DataSource simply wraps a {@link ConnectionPool} in order to provide a standard interface to the user.
  * @author Filip Hanik
  * @version 1.0
  */
 public class DataSource extends DataSourceProxy implements MBeanRegistration,javax.sql.DataSource, org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean {
 
+    /**
+     * Constructor for reflection only. A default set of pool properties will be created.
+     */
     public DataSource() {
         super();
     }
-
-    public DataSource(PoolProperties poolProperties) {
+    
+    /**
+     * Constructs a DataSource object wrapping a connection
+     * @param poolProperties
+     */
+    public DataSource(PoolConfiguration poolProperties) {
         super(poolProperties);
     }
 
 //===============================================================================
-//  Register the actual pool itself under the tomcat.jdbc domain
+//  JMX Operations - Register the actual pool itself under the tomcat.jdbc domain
 //===============================================================================
     protected volatile ObjectName oname = null;
 
@@ -122,6 +129,9 @@
         }
     }
     
+    /**
+     * 
+     */
     protected void unregisterJmx() {
         try {
             MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
@@ -132,422 +142,5 @@
         }
     }
 
-//===============================================================================
-//  Expose JMX attributes through Tomcat's dynamic reflection
-//===============================================================================
-    /**
-     * Forces an abandon check on the connection pool.
-     * If connections that have been abandoned exists, they will be closed during this run
-     */
-    public void checkAbandoned() {
-        try {
-            createPool().checkAbandoned();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * Forces a check for downsizing the idle connections
-     */
-    public void checkIdle() {
-        try {
-            createPool().checkIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return number of connections in use by the application
-     */
-    public int getActive() {
-        try {
-            return createPool().getActive();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-    
-    /**
-     * @return number of connections in use by the application
-     * {@link DataSource#getActive()}
-     */
-    public int getNumActive() {
-        return getActive();
-    }
-
-    /**
-     * @return number of threads waiting for a connection
-     */
-    public int getWaitCount() {
-        try {
-            return createPool().getWaitCount();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * NOT USED ANYWHERE
-     * @return nothing 
-     */
-    public String getConnectionProperties() {
-        try {
-            return createPool().getPoolProperties().getConnectionProperties();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return connection properties passed into the JDBC Driver upon connect
-     */
-    public Properties getDbProperties() {
-        try {
-            return createPool().getPoolProperties().getDbProperties();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured default catalog
-     */
-    public String getDefaultCatalog() {
-        try {
-            return createPool().getPoolProperties().getDefaultCatalog();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured default isolation level
-     */
-    public int getDefaultTransactionIsolation() {
-        try {
-            return createPool().getPoolProperties().getDefaultTransactionIsolation();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured driver class name
-     */
-    public String getDriverClassName() {
-        try {
-            return createPool().getPoolProperties().getDriverClassName();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the number of established but idle connections
-     */
-    public int getIdle() {
-        try {
-            return createPool().getIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * {@link #getIdle()}
-     */
-    public int getNumIdle() {
-        return getIdle();
-    }
-
-    /**
-     * @return the configured number of initial connections 
-     */
-    public int getInitialSize() {
-        try {
-            return createPool().getPoolProperties().getInitialSize();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured initialization SQL 
-     */
-    public String getInitSQL() {
-        try {
-            return createPool().getPoolProperties().getInitSQL();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configuration string for interceptors
-     */
-    public String getJdbcInterceptors() {
-        try {
-            return createPool().getPoolProperties().getJdbcInterceptors();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured number of maximum allowed connections
-     */
-    public int getMaxActive() {
-        try {
-            return createPool().getPoolProperties().getMaxActive();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured number of maximum idle connections
-     */
-    public int getMaxIdle() {
-        try {
-            return createPool().getPoolProperties().getMaxIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured maximum wait time in milliseconds if a connection is not available
-     */
-    public int getMaxWait() {
-        try {
-            return createPool().getPoolProperties().getMaxWait();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured idle time, before a connection that is idle can be released
-     */
-    public int getMinEvictableIdleTimeMillis() {
-        try {
-            return createPool().getPoolProperties().getMinEvictableIdleTimeMillis();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured minimum amount of idle connections 
-     */
-    public int getMinIdle() {
-        try {
-            return createPool().getPoolProperties().getMinIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-    
-    /**
-     * @return the configured maxAge for a connection.
-     * A connection that has been established for longer than this configured value in milliseconds
-     * will be closed upon a return
-     */
-    public long getMaxAge() {
-        try {
-            return createPool().getPoolProperties().getMaxAge();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }    
-
-    /**
-     * @return the name of the pool
-     */
-    public String getName() {
-        try {
-            return createPool().getName();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the configured value - not used in this implementation
-     */
-    public int getNumTestsPerEvictionRun() {
-        try {
-            return createPool().getPoolProperties().getNumTestsPerEvictionRun();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return DOES NOT RETURN THE PASSWORD, IT WOULD SHOW UP IN JMX
-     */
-    public String getPassword() {
-        return "Password not available as DataSource/JMX operation.";
-    }
-
-    /**
-     * @return the configured remove abandoned timeout in seconds
-     */
-    public int getRemoveAbandonedTimeout() {
-        try {
-            return createPool().getPoolProperties().getRemoveAbandonedTimeout();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    /**
-     * @return the current size of the pool
-     */
-    public int getSize() {
-        try {
-            return createPool().getSize();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public int getTimeBetweenEvictionRunsMillis() {
-        try {
-            return createPool().getPoolProperties().getTimeBetweenEvictionRunsMillis();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public String getUrl() {
-        try {
-            return createPool().getPoolProperties().getUrl();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public String getUsername() {
-        try {
-            return createPool().getPoolProperties().getUsername();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public long getValidationInterval() {
-        try {
-            return createPool().getPoolProperties().getValidationInterval();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public String getValidationQuery() {
-        try {
-            return createPool().getPoolProperties().getValidationQuery();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isAccessToUnderlyingConnectionAllowed() {
-        try {
-            return createPool().getPoolProperties().isAccessToUnderlyingConnectionAllowed();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isDefaultAutoCommit() {
-        try {
-            return createPool().getPoolProperties().isDefaultAutoCommit();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isDefaultReadOnly() {
-        try {
-            return createPool().getPoolProperties().isDefaultReadOnly();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isLogAbandoned() {
-        try {
-            return createPool().getPoolProperties().isLogAbandoned();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isPoolSweeperEnabled() {
-        try {
-            return createPool().getPoolProperties().isPoolSweeperEnabled();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isRemoveAbandoned() {
-        try {
-            return createPool().getPoolProperties().isRemoveAbandoned();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public int getAbandonWhenPercentageFull() {
-        try {
-            return createPool().getPoolProperties().getAbandonWhenPercentageFull();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isTestOnBorrow() {
-        try {
-            return createPool().getPoolProperties().isTestOnBorrow();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isTestOnConnect() {
-        try {
-            return createPool().getPoolProperties().isTestOnConnect();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isTestOnReturn() {
-        try {
-            return createPool().getPoolProperties().isTestOnReturn();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public boolean isTestWhileIdle() {
-        try {
-            return createPool().getPoolProperties().isTestWhileIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public void testIdle() {
-        try {
-            createPool().testAllIdle();
-        }catch (SQLException x) {
-            throw new RuntimeException(x);
-        }
-    }
 
 }

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java Mon Jul 13 22:18:17 2009
@@ -210,8 +210,8 @@
         return createDataSource(properties);
     }
     
-    public static PoolProperties parsePoolProperties(Properties properties) throws IOException{
-        PoolProperties poolProperties = new PoolProperties();
+    public static PoolConfiguration parsePoolProperties(Properties properties) throws IOException{
+        PoolConfiguration poolProperties = new PoolProperties();
         String value = null;
 
         value = properties.getProperty(PROP_DEFAULTAUTOCOMMIT);
@@ -442,7 +442,7 @@
      * @throws Exception if an error occurs creating the data source
      */
     public static DataSource createDataSource(Properties properties) throws Exception {
-        PoolProperties poolProperties = DataSourceFactory.parsePoolProperties(properties);
+        PoolConfiguration poolProperties = DataSourceFactory.parsePoolProperties(properties);
         org.apache.tomcat.jdbc.pool.DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
         
         //initialize the pool itself
@@ -466,11 +466,7 @@
      * @throws Exception
      */
     static protected Properties getProperties(String propText) throws IOException {
-        Properties p = new Properties();
-        if (propText != null) {
-            p.load(new ByteArrayInputStream(propText.replace(';', '\n').getBytes()));
-        }
-        return p;
+        return PoolProperties.getProperties(propText,null);
     }
 
     protected static class DataSourceHandler implements InvocationHandler {

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=793732&r1=793731&r2=793732&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 Mon Jul 13 22:18:17 2009
@@ -20,6 +20,7 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Iterator;
+import java.util.Properties;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -27,28 +28,34 @@
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
 
 /**
  *
  * The DataSource proxy lets us implements methods that don't exist in the current 
  * compiler JDK but might be methods that are part of a future JDK DataSource interface.
+ * <br/>
+ * It's a trick to work around compiler issues when implementing interfaces. For example, 
+ * I could put in Java 6 methods of javax.sql.DataSource here, and compile it with JDK 1.5
+ * and still be able to run under Java 6 without getting NoSuchMethodException.
  *
  * @author Filip Hanik
  * @version 1.0
  */
 
-public class DataSourceProxy  {
+public class DataSourceProxy implements PoolConfiguration {
     protected static Log log = LogFactory.getLog(DataSourceProxy.class);
     
     protected volatile ConnectionPool pool = null;
     
-    protected PoolProperties poolProperties = null;
+    protected PoolConfiguration poolProperties = null;
 
     public DataSourceProxy() {
         this(new PoolProperties());
     }
     
-    public DataSourceProxy(PoolProperties poolProperties) {
+    public DataSourceProxy(PoolConfiguration poolProperties) {
+        if (poolProperties == null) throw new NullPointerException("PoolConfiguration can not be null.");
         this.poolProperties = poolProperties;
     }
     
@@ -72,7 +79,7 @@
         return getConnection();
     }
 
-    public PoolProperties getPoolProperties() {
+    public PoolConfiguration getPoolProperties() {
         return poolProperties;
     }
 
@@ -130,13 +137,7 @@
         return pool;
     }
 
-    public String getPoolName() {
-        return pool.getName();
-    }
-
     
-
-
     public void close() {
         close(false);
     }
@@ -155,14 +156,14 @@
     }
 
     protected void finalize() throws Throwable {
-        //terminate the pool?
-        ThreadPoolExecutor closer = new ThreadPoolExecutor(0,1,1000,TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
-        final Runnable r = new Runnable() {
-            public void run(){ 
-                close(true);                
-            }
-        };
-        closer.execute(r);
+//        //terminate the pool?
+//        ThreadPoolExecutor closer = new ThreadPoolExecutor(0,1,1000,TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
+//        final Runnable r = new Runnable() {
+//            public void run(){ 
+//                close(true);                
+//            }
+//        };
+//        closer.execute(r);
     }
 
     public int getPoolSize() throws SQLException{
@@ -174,135 +175,265 @@
     public String toString() {
         return super.toString()+"{"+getPoolProperties()+"}";
     }
+
+
+
     
 /*-----------------------------------------------------------------------*/
 //      PROPERTIES WHEN NOT USED WITH FACTORY
 /*------------------------------------------------------------------------*/
    
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getPoolName() {
+        return pool.getName();
+    }
    
    
-    public void setPoolProperties(PoolProperties poolProperties) {
+    public void setPoolProperties(PoolConfiguration poolProperties) {
         this.poolProperties = poolProperties;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDriverClassName(String driverClassName) {
         this.poolProperties.setDriverClassName(driverClassName);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setInitialSize(int initialSize) {
         this.poolProperties.setInitialSize(initialSize);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setInitSQL(String initSQL) {
         this.poolProperties.setInitSQL(initSQL);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setLogAbandoned(boolean logAbandoned) {
         this.poolProperties.setLogAbandoned(logAbandoned);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxActive(int maxActive) {
         this.poolProperties.setMaxActive(maxActive);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxIdle(int maxIdle) {
         this.poolProperties.setMaxIdle(maxIdle);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxWait(int maxWait) {
         this.poolProperties.setMaxWait(maxWait);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
         this.poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMinIdle(int minIdle) {
         this.poolProperties.setMinIdle(minIdle);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
         this.poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setPassword(String password) {
         this.poolProperties.setPassword(password);
         this.poolProperties.getDbProperties().setProperty("password",this.poolProperties.getPassword());
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setRemoveAbandoned(boolean removeAbandoned) {
         this.poolProperties.setRemoveAbandoned(removeAbandoned);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
         this.poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnBorrow(boolean testOnBorrow) {
         this.poolProperties.setTestOnBorrow(testOnBorrow);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnConnect(boolean testOnConnect) {
         this.poolProperties.setTestOnConnect(testOnConnect);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnReturn(boolean testOnReturn) {
         this.poolProperties.setTestOnReturn(testOnReturn);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestWhileIdle(boolean testWhileIdle) {
         this.poolProperties.setTestWhileIdle(testWhileIdle);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
         this.poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUrl(String url) {
         this.poolProperties.setUrl(url);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUsername(String username) {
         this.poolProperties.setUsername(username);
         this.poolProperties.getDbProperties().setProperty("user",getPoolProperties().getUsername());
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setValidationInterval(long validationInterval) {
         this.poolProperties.setValidationInterval(validationInterval);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setValidationQuery(String validationQuery) {
         this.poolProperties.setValidationQuery(validationQuery);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setJdbcInterceptors(String interceptors) {
         this.getPoolProperties().setJdbcInterceptors(interceptors);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setJmxEnabled(boolean enabled) {
         this.getPoolProperties().setJmxEnabled(enabled);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setFairQueue(boolean fairQueue) {
         this.getPoolProperties().setFairQueue(fairQueue);
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUseLock(boolean useLock) {
         this.getPoolProperties().setUseLock(useLock);
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultCatalog(String catalog) {
         this.getPoolProperties().setDefaultCatalog(catalog);
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultAutoCommit(Boolean autocommit) {
         this.getPoolProperties().setDefaultAutoCommit(autocommit);
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
         this.getPoolProperties().setDefaultTransactionIsolation(defaultTransactionIsolation);
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setConnectionProperties(String properties) {
         try {
             java.util.Properties prop = DataSourceFactory
@@ -320,6 +451,10 @@
         }
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUseEquals(boolean useEquals) {
         this.getPoolProperties().setUseEquals(useEquals);
     }
@@ -332,13 +467,16 @@
         return null;
     }
 
+
     /**
+     * no-op
      * {@link javax.sql.DataSource#setLogWriter(PrintWriter)}
      */
     public void setLogWriter(PrintWriter out) throws SQLException {
     }
 
     /**
+     * no-op
      * {@link javax.sql.DataSource#getLoginTimeout}
      */
     public int getLoginTimeout() {
@@ -360,7 +498,483 @@
         }
 
     }    
+    
+  //===============================================================================
+//  Expose JMX attributes through Tomcat's dynamic reflection
+//===============================================================================
+    /**
+     * If the pool has not been created, it will be created during this call.
+     * @return the number of established but idle connections
+     */
+    public int getIdle() {
+        try {
+            return createPool().getIdle();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * {@link #getIdle()}
+     */
+    public int getNumIdle() {
+        return getIdle();
+    }
+
+    /**
+     * Forces an abandon check on the connection pool.
+     * If connections that have been abandoned exists, they will be closed during this run
+     */
+    public void checkAbandoned() {
+        try {
+            createPool().checkAbandoned();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * Forces a check for resizing of the idle connections
+     */
+    public void checkIdle() {
+        try {
+            createPool().checkIdle();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * @return number of connections in use by the application
+     */
+    public int getActive() {
+        try {
+            return createPool().getActive();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+    
+    /**
+     * @return number of connections in use by the application
+     * {@link DataSource#getActive()}
+     */
+    public int getNumActive() {
+        return getActive();
+    }
+
+    /**
+     * @return number of threads waiting for a connection
+     */
+    public int getWaitCount() {
+        try {
+            return createPool().getWaitCount();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * @return the current size of the pool
+     */
+    public int getSize() {
+        try {
+            return createPool().getSize();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * Performs a validation on idle connections
+     */
+    public void testIdle() {
+        try {
+            createPool().testAllIdle();
+        }catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }    
+    //=========================================================
+    //  PROPERTIES / CONFIGURATION
+    //=========================================================    
+    
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getConnectionProperties() {
+        return getPoolProperties().getConnectionProperties();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Properties getDbProperties() {
+        return getPoolProperties().getDbProperties();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getDefaultCatalog() {
+        return getPoolProperties().getDefaultCatalog();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getDefaultTransactionIsolation() {
+        return getPoolProperties().getDefaultTransactionIsolation();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getDriverClassName() {
+        return getPoolProperties().getDriverClassName();
+    }
+
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getInitialSize() {
+        return getPoolProperties().getInitialSize();
+    }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getInitSQL() {
+        return getPoolProperties().getInitSQL();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getJdbcInterceptors() {
+        return getPoolProperties().getJdbcInterceptors();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getMaxActive() {
+        return getPoolProperties().getMaxActive();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getMaxIdle() {
+        return getPoolProperties().getMaxIdle();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getMaxWait() {
+        return getPoolProperties().getMaxWait();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getMinEvictableIdleTimeMillis() {
+        return getPoolProperties().getMinEvictableIdleTimeMillis();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getMinIdle() {
+        return getPoolProperties().getMinIdle();
+    }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public long getMaxAge() {
+        return getPoolProperties().getMaxAge();
+    }    
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return getName();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getNumTestsPerEvictionRun() {
+        return getPoolProperties().getNumTestsPerEvictionRun();
+    }
+
+    /**
+     * @return DOES NOT RETURN THE PASSWORD, IT WOULD SHOW UP IN JMX
+     */
+    public String getPassword() {
+        return "Password not available as DataSource/JMX operation.";
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getRemoveAbandonedTimeout() {
+        return getPoolProperties().getRemoveAbandonedTimeout();
+    }
+
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getTimeBetweenEvictionRunsMillis() {
+        return getPoolProperties().getTimeBetweenEvictionRunsMillis();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getUrl() {
+        return getPoolProperties().getUrl();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getUsername() {
+        return getPoolProperties().getUsername();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public long getValidationInterval() {
+        return getPoolProperties().getValidationInterval();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public String getValidationQuery() {
+        return getPoolProperties().getValidationQuery();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isAccessToUnderlyingConnectionAllowed() {
+        return getPoolProperties().isAccessToUnderlyingConnectionAllowed();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean isDefaultAutoCommit() {
+        return getPoolProperties().isDefaultAutoCommit();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean isDefaultReadOnly() {
+        return getPoolProperties().isDefaultReadOnly();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isLogAbandoned() {
+        return getPoolProperties().isLogAbandoned();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isPoolSweeperEnabled() {
+        return getPoolProperties().isPoolSweeperEnabled();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isRemoveAbandoned() {
+        return getPoolProperties().isRemoveAbandoned();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public int getAbandonWhenPercentageFull() {
+        return getPoolProperties().getAbandonWhenPercentageFull();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isTestOnBorrow() {
+        return getPoolProperties().isTestOnBorrow();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isTestOnConnect() {
+        return getPoolProperties().isTestOnConnect();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isTestOnReturn() {
+        return getPoolProperties().isTestOnReturn();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isTestWhileIdle() {
+        return getPoolProperties().isTestWhileIdle();
+    }
+
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean getDefaultAutoCommit() {
+        return getPoolProperties().getDefaultAutoCommit();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean getDefaultReadOnly() {
+        return getPoolProperties().getDefaultReadOnly();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
+        return getPoolProperties().getJdbcInterceptorsAsArray();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean getUseLock() {
+        return getPoolProperties().getUseLock();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isFairQueue() {
+        return getPoolProperties().isFairQueue();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isJmxEnabled() {
+        return getPoolProperties().isJmxEnabled();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isUseEquals() {
+        return getPoolProperties().isUseEquals();
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setAbandonWhenPercentageFull(int percentage) {
+        getPoolProperties().setAbandonWhenPercentageFull(percentage);
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
+        getPoolProperties().setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDbProperties(Properties dbProperties) {
+        getPoolProperties().setDbProperties(dbProperties);
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDefaultReadOnly(Boolean defaultReadOnly) {
+        getPoolProperties().setDefaultReadOnly(defaultReadOnly);
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setMaxAge(long maxAge) {
+        getPoolProperties().setMaxAge(maxAge);
+    }
+
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setName(String name) {
+        getPoolProperties().setName(name);
+    }
     
 }

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java Mon Jul 13 22:18:17 2009
@@ -32,17 +32,36 @@
  *
  * A simple implementation of a blocking queue with fairness waiting.
  * invocations to method poll(...) will get handed out in the order they were received.
+ * Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a 
+ * lock per thread basis so that order is guaranteed once the thread goes into a suspended monitor state.
+ * <br/>
+ * Not all of the methods of the {@link java.util.concurrent.BlockingQueue} are implemented.
  * @author Filip Hanik
  *
  */
 
 public class FairBlockingQueue<E> implements BlockingQueue<E> {
-    ReentrantLock lock = new ReentrantLock(false);
+    
+    /**
+     * Phase one entry lock in order to give out 
+     * per-thread-locks for the waiting phase we have 
+     * a phase one lock during the contention period.
+     */
+    final ReentrantLock lock = new ReentrantLock(false);
 
-    LinkedList<E> items = null;
+    /**
+     * All the objects in the pool are stored in a simple linked list
+     */
+    final LinkedList<E> items;
 
-    LinkedList<ExchangeCountDownLatch<E>> waiters = null;
+    /**
+     * All threads waiting for an object are stored in a linked list
+     */
+    final LinkedList<ExchangeCountDownLatch<E>> waiters;
     
+    /**
+     * Creates a new fair blocking queue.
+     */
     public FairBlockingQueue() {
         items = new LinkedList<E>();
         waiters = new LinkedList<ExchangeCountDownLatch<E>>();
@@ -52,27 +71,37 @@
     // USED BY CONPOOL IMPLEMENTATION
     //------------------------------------------------------------------
     /**
+     * Will always return true, queue is unbounded.
      * {@inheritDoc}
      */
     public boolean offer(E e) {
+        //during the offer, we will grab the main lock
         final ReentrantLock lock = this.lock;
         lock.lock();
         ExchangeCountDownLatch<E> c = null;
         try {
+            //check to see if threads are waiting for an object
             if (waiters.size() > 0) {
+                //if threads are waiting grab the latch for that thread
                 c = waiters.poll();
+                //give the object to the thread instead of adding it to the pool
                 c.setItem(e);
             } else {
+                //we always add first, so that the most recently used object will be given out
                 items.addFirst(e);
             }
         } finally {
             lock.unlock();
         }
+        //if we exchanged an object with another thread, wake it up.
         if (c!=null) c.countDown();
+        //we have an unbounded queue, so always return true
         return true;
     }
 
     /**
+     * Will never timeout, as it invokes the {@link #offer(Object)} method.
+     * Once a lock has been acquired, the  
      * {@inheritDoc}
      */
     public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
@@ -80,26 +109,37 @@
     }
 
     /**
+     * Fair retrieval of an object in the queue.
+     * Objects are returned in the order the threads requested them.
      * {@inheritDoc}
      */
     public E poll(long timeout, TimeUnit unit) throws InterruptedException {
         E result = null;
         final ReentrantLock lock = this.lock;
         boolean error = true;
+        //acquire the global lock until we know what to do
         lock.lock();
         try {
+            //check to see if we have objects
             result = items.poll();
             if (result==null && timeout>0) {
+                //the queue is empty we will wait for an object
                 ExchangeCountDownLatch<E> c = new ExchangeCountDownLatch<E>(1);
+                //add to the bottom of the wait list
                 waiters.addLast(c);
+                //unlock the global lock
                 lock.unlock();
+                //wait for the specified timeout
                 if (!c.await(timeout, unit)) {
+                    //if we timed out, remove ourselves from the waitlist
                     lock.lock();
                     waiters.remove(c);
                     lock.unlock();
                 }
+                //return the item we received, can be null if we timed out
                 result = c.getItem();
             } else {
+                //we have an object, release
                 lock.unlock();
             }
             error = false;
@@ -119,16 +159,21 @@
         Future<E> result = null;
         final ReentrantLock lock = this.lock;
         boolean error = true;
+        //grab the global lock
         lock.lock();
         try {
+            //check to see if we have objects in the queue
             E item = items.poll();
             if (item==null) {
+                //queue is empty, add ourselves as waiters
                 ExchangeCountDownLatch<E> c = new ExchangeCountDownLatch<E>(1);
                 waiters.addLast(c);
                 lock.unlock();
+                //return a future that will wait for the object
                 result = new ItemFuture(c);
             } else {
                 lock.unlock();
+                //return a future with the item
                 result = new ItemFuture(item);
             }
             error = false;

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Mon Jul 13 22:18:17 2009
@@ -17,6 +17,8 @@
 package org.apache.tomcat.jdbc.pool;
 
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,8 +32,7 @@
  * @author Filip Hanik
  *
  */
-public class PoolProperties {
-    public static final String PKG_PREFIX = "org.apache.tomcat.jdbc.pool.interceptor.";
+public class PoolProperties implements PoolConfiguration {
     protected static Log log = LogFactory.getLog(PoolProperties.class);
     
     protected static AtomicInteger poolCounter = new AtomicInteger(0);
@@ -55,11 +56,10 @@
     protected int timeBetweenEvictionRunsMillis = 5000;
     protected int numTestsPerEvictionRun;
     protected int minEvictableIdleTimeMillis = 60000;
-    protected boolean accessToUnderlyingConnectionAllowed;
+    protected final boolean accessToUnderlyingConnectionAllowed = true;
     protected boolean removeAbandoned = false;
     protected int removeAbandonedTimeout = 60;
     protected boolean logAbandoned = false;
-    protected int loginTimeout = 10000;
     protected String name = "Tomcat Connection Pool["+(poolCounter.addAndGet(1))+"-"+System.identityHashCode(PoolProperties.class)+"]";
     protected String password;
     protected String username;
@@ -75,156 +75,300 @@
     protected boolean useLock = false;
     private InterceptorDefinition[] interceptors = null;
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setAbandonWhenPercentageFull(int percentage) {
         if (percentage<0) abandonWhenPercentageFull = 0;
         else if (percentage>100) abandonWhenPercentageFull = 100;
         else abandonWhenPercentageFull = percentage;
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getAbandonWhenPercentageFull() {
         return abandonWhenPercentageFull;
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isFairQueue() {
         return fairQueue;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setFairQueue(boolean fairQueue) {
         this.fairQueue = fairQueue;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isAccessToUnderlyingConnectionAllowed() {
         return accessToUnderlyingConnectionAllowed;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getConnectionProperties() {
         return connectionProperties;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public Properties getDbProperties() {
         return dbProperties;
     }
 
-    public boolean isDefaultAutoCommit() {
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean isDefaultAutoCommit() {
         return defaultAutoCommit;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getDefaultCatalog() {
         return defaultCatalog;
     }
 
-    public boolean isDefaultReadOnly() {
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public Boolean isDefaultReadOnly() {
         return defaultReadOnly;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getDefaultTransactionIsolation() {
         return defaultTransactionIsolation;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getDriverClassName() {
         return driverClassName;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getInitialSize() {
         return initialSize;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isLogAbandoned() {
         return logAbandoned;
     }
 
-    public int getLoginTimeout() {
-        return loginTimeout;
-    }
-
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getMaxActive() {
         return maxActive;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getMaxIdle() {
         return maxIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getMaxWait() {
         return maxWait;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getMinEvictableIdleTimeMillis() {
         return minEvictableIdleTimeMillis;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getMinIdle() {
         return minIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getName() {
         return name;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getNumTestsPerEvictionRun() {
         return numTestsPerEvictionRun;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getPassword() {
         return password;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getPoolName() {
         return getName();
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isRemoveAbandoned() {
         return removeAbandoned;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getRemoveAbandonedTimeout() {
         return removeAbandonedTimeout;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isTestOnBorrow() {
         return testOnBorrow;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isTestOnReturn() {
         return testOnReturn;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isTestWhileIdle() {
         return testWhileIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public int getTimeBetweenEvictionRunsMillis() {
         return timeBetweenEvictionRunsMillis;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getUrl() {
         return url;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getUsername() {
         return username;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getValidationQuery() {
         return validationQuery;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public long getValidationInterval() {
         return validationInterval;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getInitSQL() {
         return initSQL;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isTestOnConnect() {
         return testOnConnect;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public String getJdbcInterceptors() {
         return jdbcInterceptors;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
         if (interceptors == null) {
             if (jdbcInterceptors==null) {
@@ -256,133 +400,251 @@
         return interceptors;
     }
 
-    public void setAccessToUnderlyingConnectionAllowed(boolean
-        accessToUnderlyingConnectionAllowed) {
-        this.accessToUnderlyingConnectionAllowed =
-            accessToUnderlyingConnectionAllowed;
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
+    public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setConnectionProperties(String connectionProperties) {
         this.connectionProperties = connectionProperties;
+        getProperties(connectionProperties, getDbProperties());
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDbProperties(Properties dbProperties) {
         this.dbProperties = dbProperties;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
         this.defaultAutoCommit = defaultAutoCommit;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultCatalog(String defaultCatalog) {
         this.defaultCatalog = defaultCatalog;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultReadOnly(Boolean defaultReadOnly) {
         this.defaultReadOnly = defaultReadOnly;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
         this.defaultTransactionIsolation = defaultTransactionIsolation;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setDriverClassName(String driverClassName) {
         this.driverClassName = driverClassName;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setInitialSize(int initialSize) {
         this.initialSize = initialSize;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setLogAbandoned(boolean logAbandoned) {
         this.logAbandoned = logAbandoned;
     }
 
-    public void setLoginTimeout(int loginTimeout) {
-        this.loginTimeout = loginTimeout;
-    }
-
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxActive(int maxActive) {
         this.maxActive = maxActive;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxIdle(int maxIdle) {
         this.maxIdle = maxIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxWait(int maxWait) {
         this.maxWait = maxWait;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
         this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMinIdle(int minIdle) {
         this.minIdle = minIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setName(String name) {
         this.name = name;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
         this.numTestsPerEvictionRun = numTestsPerEvictionRun;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setPassword(String password) {
         this.password = password;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setRemoveAbandoned(boolean removeAbandoned) {
         this.removeAbandoned = removeAbandoned;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
         this.removeAbandonedTimeout = removeAbandonedTimeout;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnBorrow(boolean testOnBorrow) {
         this.testOnBorrow = testOnBorrow;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestWhileIdle(boolean testWhileIdle) {
         this.testWhileIdle = testWhileIdle;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnReturn(boolean testOnReturn) {
         this.testOnReturn = testOnReturn;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTimeBetweenEvictionRunsMillis(int
                                                  timeBetweenEvictionRunsMillis) {
         this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUrl(String url) {
         this.url = url;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUsername(String username) {
         this.username = username;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setValidationInterval(long validationInterval) {
         this.validationInterval = validationInterval;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setValidationQuery(String validationQuery) {
         this.validationQuery = validationQuery;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setInitSQL(String initSQL) {
         this.initSQL = initSQL;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setTestOnConnect(boolean testOnConnect) {
         this.testOnConnect = testOnConnect;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setJdbcInterceptors(String jdbcInterceptors) {
         this.jdbcInterceptors = jdbcInterceptors;
         this.interceptors = null;
@@ -422,22 +684,42 @@
         return poolCounter.get();
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isJmxEnabled() {
         return jmxEnabled;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setJmxEnabled(boolean jmxEnabled) {
         this.jmxEnabled = jmxEnabled;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public Boolean getDefaultAutoCommit() {
         return defaultAutoCommit;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public Boolean getDefaultReadOnly() {
         return defaultReadOnly;
     }
     
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isPoolSweeperEnabled() {
         boolean result = getTimeBetweenEvictionRunsMillis()>0;
         result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
@@ -475,9 +757,9 @@
             if (clazz==null) {
                 if (getClassName().indexOf(".")<0) {
                     if (log.isDebugEnabled()) {
-                        log.debug("Loading interceptor class:"+PoolProperties.PKG_PREFIX+getClassName());
+                        log.debug("Loading interceptor class:"+PoolConfiguration.PKG_PREFIX+getClassName());
                     }
-                    clazz = Class.forName(PoolProperties.PKG_PREFIX+getClassName(), true, this.getClass().getClassLoader());
+                    clazz = Class.forName(PoolConfiguration.PKG_PREFIX+getClassName(), true, this.getClass().getClassLoader());
                 } else {
                     if (log.isDebugEnabled()) {
                         log.debug("Loading interceptor class:"+getClassName());
@@ -516,30 +798,64 @@
         }
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean isUseEquals() {
         return useEquals;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUseEquals(boolean useEquals) {
         this.useEquals = useEquals;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public long getMaxAge() {
         return maxAge;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setMaxAge(long maxAge) {
         this.maxAge = maxAge;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public boolean getUseLock() {
         return useLock;
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    @Override
     public void setUseLock(boolean useLock) {
         this.useLock = useLock;
     }
     
         
-
+    public static Properties getProperties(String propText, Properties props) {
+        if (props==null) props = new Properties();
+        if (propText != null) {
+            try {
+                props.load(new ByteArrayInputStream(propText.replace(';', '\n').getBytes()));
+            }catch (IOException x) {
+                throw new RuntimeException(x);
+            }
+        }
+        return props;
+    }
 }

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java Mon Jul 13 22:18:17 2009
@@ -65,7 +65,7 @@
     /**
      * The properties for the connection pool
      */
-    protected PoolProperties poolProperties;
+    protected PoolConfiguration poolProperties;
     /**
      * The underlying database connection
      */
@@ -112,7 +112,7 @@
     
     private AtomicBoolean released = new AtomicBoolean(false);
     
-    public PooledConnection(PoolProperties prop, ConnectionPool parent) {
+    public PooledConnection(PoolConfiguration prop, ConnectionPool parent) {
         instanceCount = counter.addAndGet(1);
         poolProperties = prop;
         this.parent = parent;
@@ -341,7 +341,7 @@
         this.lastValidated = lastValidated;
     }
 
-    public void setPoolProperties(PoolProperties poolProperties) {
+    public void setPoolProperties(PoolConfiguration poolProperties) {
         this.poolProperties = poolProperties;
     }
 
@@ -357,7 +357,7 @@
         return lastValidated;
     }
 
-    public PoolProperties getPoolProperties() {
+    public PoolConfiguration getPoolProperties() {
         return poolProperties;
     }
 

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java Mon Jul 13 22:18:17 2009
@@ -24,7 +24,7 @@
 import org.apache.tomcat.jdbc.pool.ConnectionPool;
 import org.apache.tomcat.jdbc.pool.DataSourceFactory;
 import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
-import org.apache.tomcat.jdbc.pool.PoolProperties;
+import org.apache.tomcat.jdbc.pool.PoolConfiguration;
 import org.apache.tomcat.jdbc.pool.PooledConnection;
 
 /**
@@ -46,7 +46,7 @@
     
     
     public void reset(ConnectionPool parent, PooledConnection con) {
-        PoolProperties poolProperties = parent.getPoolProperties();
+        PoolConfiguration poolProperties = parent.getPoolProperties();
         if (poolProperties.getDefaultReadOnly()!=null) {
             try {
                 if (readOnly==null || readOnly.booleanValue()!=poolProperties.getDefaultReadOnly().booleanValue()) {

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java?rev=793732&r1=793731&r2=793732&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Mon Jul 13 22:18:17 2009
@@ -29,6 +29,8 @@
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.jdbc.pool.PoolConfiguration;
+import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
 
 public class ConnectionPool extends NotificationBroadcasterSupport implements ConnectionPoolMBean  {
     /**
@@ -59,6 +61,10 @@
         return pool;
     }
     
+    public PoolConfiguration getPoolProperties() {
+        return pool.getPoolProperties();
+    }
+    
     //=================================================================
     //       NOTIFICATION INFO
     //=================================================================
@@ -140,10 +146,6 @@
         return pool.getActive();
     }
     
-    public boolean isPoolSweeperEnabled() {
-        return pool.getPoolProperties().isPoolSweeperEnabled();
-    }
-    
     public int getNumIdle() {
         return getIdle();
     }
@@ -151,6 +153,10 @@
     public int getNumActive() {
         return getActive();
     }
+    
+    public int getWaitCount() {
+        return pool.getWaitCount();
+    }
 
     //=================================================================
     //       POOL OPERATIONS
@@ -169,110 +175,384 @@
     //=================================================================
     //       POOL PROPERTIES
     //=================================================================
-    public Properties getDbProperties() {
-        return null; //pool.getPoolProperties().getDbProperties();
-    }
-    public String getUrl() {
-        return pool.getPoolProperties().getUrl();
-    }
-    public String getDriverClassName() {
-        return pool.getPoolProperties().getDriverClassName();
+    //=========================================================
+    //  PROPERTIES / CONFIGURATION
+    //=========================================================    
+    
+    
+    
+    public String getConnectionProperties() {
+        return getPoolProperties().getConnectionProperties();
     }
-    public boolean isDefaultAutoCommit() {
-        return pool.getPoolProperties().isDefaultAutoCommit();
+
+    public Properties getDbProperties() {
+        return getPoolProperties().getDbProperties();
     }
-    public boolean isDefaultReadOnly() {
-        return pool.getPoolProperties().isDefaultReadOnly();
+
+    public String getDefaultCatalog() {
+        return getPoolProperties().getDefaultCatalog();
     }
+
     public int getDefaultTransactionIsolation() {
-        return pool.getPoolProperties().getDefaultTransactionIsolation();
-    }
-    public String getConnectionProperties() {
-        return pool.getPoolProperties().getConnectionProperties();
+        return getPoolProperties().getDefaultTransactionIsolation();
     }
-    public String getDefaultCatalog() {
-        return pool.getPoolProperties().getDefaultCatalog();
+
+    public String getDriverClassName() {
+        return getPoolProperties().getDriverClassName();
     }
+
+
     public int getInitialSize() {
-        return pool.getPoolProperties().getInitialSize();
+        return getPoolProperties().getInitialSize();
+    }
+
+    public String getInitSQL() {
+        return getPoolProperties().getInitSQL();
+    }
+
+    public String getJdbcInterceptors() {
+        return getPoolProperties().getJdbcInterceptors();
     }
+
     public int getMaxActive() {
-        return pool.getPoolProperties().getMaxActive();
+        return getPoolProperties().getMaxActive();
     }
+
     public int getMaxIdle() {
-        return pool.getPoolProperties().getMaxIdle();
+        return getPoolProperties().getMaxIdle();
     }
+
+    public int getMaxWait() {
+        return getPoolProperties().getMaxWait();
+    }
+
+    public int getMinEvictableIdleTimeMillis() {
+        return getPoolProperties().getMinEvictableIdleTimeMillis();
+    }
+
     public int getMinIdle() {
-        return pool.getPoolProperties().getMinIdle();
+        return getPoolProperties().getMinIdle();
     }
-    public int getMaxWait() {
-        return pool.getPoolProperties().getMaxWait();
+    
+    public long getMaxAge() {
+        return getPoolProperties().getMaxAge();
+    }    
+
+    public String getName() {
+        return getName();
+    }
+
+    public int getNumTestsPerEvictionRun() {
+        return getPoolProperties().getNumTestsPerEvictionRun();
     }
+
+    /**
+     * @return DOES NOT RETURN THE PASSWORD, IT WOULD SHOW UP IN JMX
+     */
+    public String getPassword() {
+        return "Password not available as DataSource/JMX operation.";
+    }
+
+    public int getRemoveAbandonedTimeout() {
+        return getPoolProperties().getRemoveAbandonedTimeout();
+    }
+
+
+    public int getTimeBetweenEvictionRunsMillis() {
+        return getPoolProperties().getTimeBetweenEvictionRunsMillis();
+    }
+
+    public String getUrl() {
+        return getPoolProperties().getUrl();
+    }
+
+    public String getUsername() {
+        return getPoolProperties().getUsername();
+    }
+
+    public long getValidationInterval() {
+        return getPoolProperties().getValidationInterval();
+    }
+
     public String getValidationQuery() {
-        return pool.getPoolProperties().getValidationQuery();
+        return getPoolProperties().getValidationQuery();
+    }
+
+    public boolean isAccessToUnderlyingConnectionAllowed() {
+        return getPoolProperties().isAccessToUnderlyingConnectionAllowed();
+    }
+
+    public Boolean isDefaultAutoCommit() {
+        return getPoolProperties().isDefaultAutoCommit();
+    }
+
+    public Boolean isDefaultReadOnly() {
+        return getPoolProperties().isDefaultReadOnly();
     }
+
+    public boolean isLogAbandoned() {
+        return getPoolProperties().isLogAbandoned();
+    }
+
+    public boolean isPoolSweeperEnabled() {
+        return getPoolProperties().isPoolSweeperEnabled();
+    }
+
+    public boolean isRemoveAbandoned() {
+        return getPoolProperties().isRemoveAbandoned();
+    }
+
+    public int getAbandonWhenPercentageFull() {
+        return getPoolProperties().getAbandonWhenPercentageFull();
+    }
+
     public boolean isTestOnBorrow() {
-        return pool.getPoolProperties().isTestOnBorrow();
+        return getPoolProperties().isTestOnBorrow();
     }
+
+    public boolean isTestOnConnect() {
+        return getPoolProperties().isTestOnConnect();
+    }
+
     public boolean isTestOnReturn() {
-        return pool.getPoolProperties().isTestOnReturn();
+        return getPoolProperties().isTestOnReturn();
     }
+
     public boolean isTestWhileIdle() {
-        return pool.getPoolProperties().isTestWhileIdle();
+        return getPoolProperties().isTestWhileIdle();
     }
-    public int getTimeBetweenEvictionRunsMillis() {
-        return pool.getPoolProperties().getTimeBetweenEvictionRunsMillis();
+
+
+    public Boolean getDefaultAutoCommit() {
+        return getPoolProperties().getDefaultAutoCommit();
     }
-    public int getNumTestsPerEvictionRun() {
-        return pool.getPoolProperties().getNumTestsPerEvictionRun();
+
+    public Boolean getDefaultReadOnly() {
+        return getPoolProperties().getDefaultReadOnly();
     }
-    public int getMinEvictableIdleTimeMillis() {
-        return pool.getPoolProperties().getMinEvictableIdleTimeMillis();
+
+    public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
+        return getPoolProperties().getJdbcInterceptorsAsArray();
     }
-    public boolean isAccessToUnderlyingConnectionAllowed() {
-        return pool.getPoolProperties().isAccessToUnderlyingConnectionAllowed();
+
+    public boolean getUseLock() {
+        return getPoolProperties().getUseLock();
     }
-    public boolean isRemoveAbandoned() {
-        return pool.getPoolProperties().isRemoveAbandoned();
+
+    public boolean isFairQueue() {
+        return getPoolProperties().isFairQueue();
     }
-    public int getRemoveAbandonedTimeout() {
-        return pool.getPoolProperties().getRemoveAbandonedTimeout();
+
+    public boolean isJmxEnabled() {
+        return getPoolProperties().isJmxEnabled();
     }
-    public boolean isLogAbandoned() {
-        return pool.getPoolProperties().isLogAbandoned();
+
+    public boolean isUseEquals() {
+        return getPoolProperties().isUseEquals();
     }
-    public int getLoginTimeout() {
-        return pool.getPoolProperties().getLoginTimeout();
+
+    public void setAbandonWhenPercentageFull(int percentage) {
+        getPoolProperties().setAbandonWhenPercentageFull(percentage);
     }
-    public String getName() {
-        return pool.getPoolProperties().getName();
+
+    public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
+        getPoolProperties().setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
     }
-    public String getPassword() {
-        return "";
+
+    public void setDbProperties(Properties dbProperties) {
+        getPoolProperties().setDbProperties(dbProperties);
     }
-    public String getUsername() {
-        return pool.getPoolProperties().getUsername();
+
+    public void setDefaultReadOnly(Boolean defaultReadOnly) {
+        getPoolProperties().setDefaultReadOnly(defaultReadOnly);
     }
-    public long getValidationInterval() {
-        return pool.getPoolProperties().getValidationInterval();
+
+    public void setMaxAge(long maxAge) {
+        getPoolProperties().setMaxAge(maxAge);
     }
-    public String getInitSQL() {
-        return pool.getPoolProperties().getInitSQL();
+
+    public void setName(String name) {
+        getPoolProperties().setName(name);
     }
-    public boolean isTestOnConnect() {
-        return pool.getPoolProperties().isTestOnConnect();
+
+    public String getPoolName() {
+        return getPoolProperties().getName();
     }
-    public String getJdbcInterceptors() {
-        return pool.getPoolProperties().getJdbcInterceptors();
+    
+
+    public void setConnectionProperties(String connectionProperties) {
+        getPoolProperties().setConnectionProperties(connectionProperties);
+        
     }
-    public int getWaitCount() {
-        return pool.getWaitCount();
+
+    public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
+        getPoolProperties().setDefaultAutoCommit(defaultAutoCommit);
     }
-    public int getAbandonWhenPercentageFull() {
-        return pool.getPoolProperties().getAbandonWhenPercentageFull();
+
+    public void setDefaultCatalog(String defaultCatalog) {
+        getPoolProperties().setDefaultCatalog(defaultCatalog);
     }
-    public long getMaxAge() {
-        return pool.getPoolProperties().getMaxAge();
+
+    public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
+        getPoolProperties().setDefaultTransactionIsolation(defaultTransactionIsolation);
+    }
+
+    public void setDriverClassName(String driverClassName) {
+        getPoolProperties().setDriverClassName(driverClassName);
+    }
+
+    public void setFairQueue(boolean fairQueue) {
+        getPoolProperties().setFairQueue(fairQueue);
+    }
+
+    @Override
+    public void setInitialSize(int initialSize) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setInitSQL(String initSQL) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setJdbcInterceptors(String jdbcInterceptors) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setJmxEnabled(boolean jmxEnabled) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setLogAbandoned(boolean logAbandoned) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setMaxActive(int maxActive) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setMaxIdle(int maxIdle) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setMaxWait(int maxWait) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setMinIdle(int minIdle) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setPassword(String password) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setRemoveAbandoned(boolean removeAbandoned) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setTestOnBorrow(boolean testOnBorrow) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setTestOnConnect(boolean testOnConnect) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setTestOnReturn(boolean testOnReturn) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setTestWhileIdle(boolean testWhileIdle) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setUrl(String url) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setUseEquals(boolean useEquals) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setUseLock(boolean useLock) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setUsername(String username) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setValidationInterval(long validationInterval) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void setValidationQuery(String validationQuery) {
+        // TODO Auto-generated method stub
+        
     }
 
 }



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