db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/pool ConnectionPool.java
Date Tue, 10 Dec 2002 20:46:08 GMT
mpoeschl    2002/12/10 12:46:08

  Modified:    src/java/org/apache/torque/pool ConnectionPool.java
  Log:
  o fix endless loop in Monitor
  o remove unused members
  o javadocs
  
  Revision  Changes    Path
  1.15      +47 -46    jakarta-turbine-torque/src/java/org/apache/torque/pool/ConnectionPool.java
  
  Index: ConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/pool/ConnectionPool.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ConnectionPool.java	26 Nov 2002 23:46:56 -0000	1.14
  +++ ConnectionPool.java	10 Dec 2002 20:46:08 -0000	1.15
  @@ -87,11 +87,6 @@
       private Stack pool;
   
       /**
  -     * The driver type for this pool.
  -     */
  -    private String driver;
  -
  -    /**
        * The url for this pool.
        */
       private String url;
  @@ -121,14 +116,14 @@
        */
       private int expiryTime; // 1 hour
   
  -     /**
  +    /**
        * Counter that keeps track of the number of threads that are in
        * the wait state, waiting to aquire a connection.
        */
       private int waitCount = 0;
   
  -    int logInterval;
  -    Monitor monitor;
  +    private int logInterval;
  +    private Monitor monitor;
   
       /**
        * Amount of time a thread asking the pool for a cached connection will
  @@ -151,10 +146,14 @@
        * Creates a <code>ConnectionPool</code> with the default
        * attributes.
        *
  -     * @param driver   The driver type for this pool.
  -     * @param url      The url for this pool.
  -     * @param username  The user name for this pool.
  +     * @param cpds The datasource
  +     * @param username The user name for this pool.
        * @param password The password for this pool.
  +     * @param maxConnections max number of connections
  +     * @param expiryTime connection expiry time
  +     * @param connectionWaitTimeout timeout
  +     * @param logInterval log interval
  +     * @param logWriter the log
        */
       ConnectionPool(ConnectionPoolDataSource cpds, String username,
                      String password, int maxConnections, int expiryTime,
  @@ -208,18 +207,14 @@
       /**
        * Returns a connection that maintains a link to the pool it came from.
        *
  -     * @param driver   The fully-qualified name of the JDBC driver to use.
  -     * @param url      The URL of the database from which the connection is
  -     *                 desired.
        * @param username The name of the database user.
        * @param password The password of the database user.
        * @return         A database connection.
  -     *
        * @exception SQLException
        */
  -    synchronized final PooledConnection
  -        getConnection(String username, String password)
  -        throws SQLException
  +    final synchronized PooledConnection getConnection(String username,
  +            String password)
  +            throws SQLException
       {
           if (username != this.username || password != this.password)
           {
  @@ -359,11 +354,10 @@
           // The connection pool was empty to start with--don't call this
           // routine if there's no connection to pop!
           // TODO: Propose general Turbine assertion failure exception? -PGO
  -        throw new Exception("Assertaion failure: Attempted to pop " +
  -                            "connection from empty pool!");
  +        throw new Exception("Assertaion failure: Attempted to pop "
  +                + "connection from empty pool!");
       }
   
  -
       /**
        * Helper method which determines whether a connection has expired.
        *
  @@ -375,8 +369,8 @@
           // Test the age of the connection (defined as current time
           // minus connection birthday) against the connection pool
           // expiration time.
  -        return (expiryTime < (System.currentTimeMillis() -
  -                 ((Long) timeStamps.get(connection)).longValue()));
  +        return (expiryTime < (System.currentTimeMillis()
  +                - ((Long) timeStamps.get(connection)).longValue()));
       }
   
       /**
  @@ -452,8 +446,9 @@
       }
   
       /**
  -     * Re
  -     turns the Total connections in the pool
  +     * Returns the Total connections in the pool
  +     *
  +     * @return total connections in the pool
        */
       int getTotalCount()
       {
  @@ -462,6 +457,8 @@
   
       /**
        * Returns the available connections in the pool
  +     *
  +     * @return number of available connections in the pool
        */
       int getNbrAvailable()
       {
  @@ -470,6 +467,8 @@
   
       /**
        * Returns the checked out connections in the pool
  +     *
  +     * @return number of checked out connections in the pool
        */
       int getNbrCheckedOut()
       {
  @@ -500,6 +499,8 @@
        * method came from a PooledConnection, and the user calls the close()
        * method of this connection object. What we need to do here is to
        * release this PooledConnection from our pool...
  +     *
  +     * @param event the connection event
        */
       public void connectionClosed(ConnectionEvent event)
       {
  @@ -509,17 +510,18 @@
       /**
        * If a fatal error occurs, close the underlying physical connection so as
        * not to be returned in the future
  +     *
  +     * @param event the connection event
        */
       public void connectionErrorOccurred(ConnectionEvent event)
       {
           try
           {
  -            System.err
  -                .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR");
  +            System.err.println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR");
               //remove this from the listener list because we are no more
               //interested in errors since we are about to close this connection
               ((PooledConnection) event.getSource())
  -                .removeConnectionEventListener(this);
  +                    .removeConnectionEventListener(this);
           }
           catch (Exception ignore)
           {
  @@ -528,7 +530,7 @@
   
           try
           {
  -            closePooledConnection((PooledConnection)event.getSource());
  +            closePooledConnection((PooledConnection) event.getSource());
           }
           catch (Exception ignore)
           {
  @@ -540,7 +542,7 @@
        * This method returns a connection to the pool, and <b>must</b>
        * be called by the requestor when finished with the connection.
        *
  -     * @param connection The database connection to release.
  +     * @param pcon The database connection to release.
        */
       private synchronized void releaseConnection(PooledConnection pcon)
       {
  @@ -557,7 +559,7 @@
   
       /**
        *
  -     * @param pcon
  +     * @param pcon The database connection to close.
        */
       private void closePooledConnection(PooledConnection pcon)
       {
  @@ -568,8 +570,8 @@
           }
           catch (Exception e)
           {
  -            log("[ERROR] Error occurred trying to close a PooledConnection." +
  -                e.getMessage());
  +            log("[ERROR] Error occurred trying to close a PooledConnection."
  +                    + e.getMessage());
           }
           finally
           {
  @@ -614,19 +616,19 @@
               {
                   buf.setLength(0);
                   buf.append(getPoolName()).append(" (in + out = total): ")
  -                   .append(getNbrAvailable()).append(" + ")
  -                   .append(getNbrCheckedOut()).append(" = ")
  -                   .append(getTotalCount());
  +                       .append(getNbrAvailable()).append(" + ")
  +                       .append(getNbrCheckedOut()).append(" = ")
  +                       .append(getTotalCount());
                   log(buf.toString());
  -            }
   
  -            // Wait for a bit.
  -            try
  -            {
  -                Thread.sleep(logInterval);
  -            }
  -            catch (InterruptedException ignored)
  -            {
  +                // Wait for a bit.
  +                try
  +                {
  +                    Thread.sleep(logInterval);
  +                }
  +                catch (InterruptedException ignored)
  +                {
  +                }
               }
           }
   
  @@ -636,4 +638,3 @@
           }
       }
   }
  -
  
  
  

Mime
View raw message