Java Mailing List Archive

http://www.junlu.com/

Home » dev.tomcat »

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

Filip Hanik - Dev Lists

2009-07-02

Replies: Find Java Web Hosting

Author LoginPost Reply
On 07/02/2009 05:10 PM, sebb wrote:
> On 02/07/2009, fhanik@apache.org<fhanik@(protected):
>  
>> Author: fhanik
>>  Date: Thu Jul 2 17:08:50 2009
>>  New Revision: 790684
>>
>>  URL: http://svn.apache.org/viewvc?rev=790684&view=rev
>>  Log:
>>  Add some doco, make shared variables volatile
>>
>>  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=790684&r1=790683&r2=790684&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 Thu Jul 2 17:08:50 2009
>>  @@(protected) @@
>>   */
>>
>>   public class ConnectionPool {
>>  +   /**
>>  +   * Prefix type for JMX registration
>>  +   */
>>     public static final String POOL_JMX_TYPE_PREFIX = "tomcat.jdbc:type=";
>>
>>  -   //logger
>>  +   /**
>>  +   * Logger
>>  +   */
>>     protected static Log log = LogFactory.getLog(ConnectionPool.class);
>>
>>     //===============================================================================
>>     //      INSTANCE/QUICK ACCESS VARIABLE
>>     //===============================================================================
>>  +   /**
>>  +   * Carries the size of the pool, instead of relying on a queue implementation
>>  +   * that usually iterates over to get an exact count
>>  +   */
>>     private AtomicInteger size = new AtomicInteger(0);
>>  +
>>     /**
>>     * All the information about the connection pool
>>  +   * These are the properties the pool got instantiated with
>>     */
>>     private PoolProperties poolProperties;
>>
>>  @@(protected) @@
>>     /**
>>     * The thread that is responsible for checking abandoned and idle threads
>>     */
>>  -   private PoolCleaner poolCleaner;
>>  +   private volatile PoolCleaner poolCleaner;
>>
>>     /**
>>     * Pool closed flag
>>     */
>>  -   private boolean closed = false;
>>  +   private volatile boolean closed = false;
>>
>>     /**
>>     * Since newProxyInstance performs the same operation, over and over
>>  @@(protected) @@
>>     private ThreadPoolExecutor cancellator = new ThreadPoolExecutor(0,1,1000,TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>());
>>
>>     /**
>>  -   * reference to mbean
>>  +   * reference to the JMX mbean
>>     */
>>     protected org.apache.tomcat.jdbc.pool.jmx.ConnectionPool jmxPool = null;
>>
>>  @@(protected) @@
>>     }
>>
>>
>>  +   /**
>>  +   * Retrieves a Connection future. If a connection is not available, one can block using future.get()
>>  +   * until a connection has become available.
>>  +   * If a connection is not retrieved, the Future must be cancelled in order for the connection to be returned
>>  +   * to the pool.
>>  +   * @return
>>    
>
> What does it return?
>  
it returns a chocolate chip cookie for patch submissions
>  
>>  +   * @throws SQLException
>>  +   */
>>     public Future<Connection> getConnectionAsync() throws SQLException {
>>       if (idle instanceof FairBlockingQueue) {
>>          Future<PooledConnection> pcf = ((FairBlockingQueue<PooledConnection>)idle).pollAsync();
>>  @@(protected) @@
>>
>>     /**
>>     * Borrows a connection from the pool
>>  -   * @return Connection - a java.sql.Connection reflection proxy, wrapping the underlying object.
>>  +   * @return Connection - a java.sql.Connection/javax.sql.PooledConnection reflection proxy, wrapping the underlying object.
>>     * @throws SQLException
>>     */
>>     public Connection getConnection() throws SQLException {
>>  @@(protected) @@
>>       return busy.size();
>>     }
>>
>>  +   /**
>>  +   * Returns the number of idle connections
>>  +   * @return
>>    
>
> Ditto
>
>  
>>  +   */
>>     public int getIdle() {
>>       return idle.size();
>>     }
>>  @@(protected) @@
>>     //===============================================================================
>>
>>
>>  +   /**
>>  +   * configures a pooled connection as a proxy
>>  +   */
>>     protected Connection setupConnection(PooledConnection con) throws SQLException {
>>  +     //fetch previous interceptor proxy
>>       JdbcInterceptor handler = con.getHandler();
>>       if (handler==null) {
>>          //build the proxy handler
>>  @@(protected) @@
>>       return proxyClassConstructor;
>>     }
>>
>>  +   /**
>>  +   * If the connection pool gets garbage collected, lets make sure we clean up
>>  +   * and close all the connections
>>  +   */
>>     @Override
>>     protected void finalize() throws Throwable {
>>       close(true);
>>
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: dev-unsubscribe@(protected)
>>  For additional commands, e-mail: dev-help@(protected)
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@(protected)
> For additional commands, e-mail: dev-help@(protected)
>
>
>  

©2008 junlu.com - Jax Systems, LLC, U.S.A.