db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/pool ConnectionPool.java TorqueClassicDataSource.java
Date Thu, 09 Jan 2003 13:33:51 GMT
henning     2003/01/09 05:33:51

  Modified:    src/java/org/apache/torque/pool ConnectionPool.java
                        TorqueClassicDataSource.java
  Log:
  - Introduce logging to the ConnectionPool class.
  
  - Removed the LogWriter from the C'tor (this is a package private
    C'tor so noone outside Torque should use it)
  
  - deprecated setLogWriter and getLogWriter in TorqueClassicDataSource
  
  Revision  Changes    Path
  1.18      +14 -22    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ConnectionPool.java	8 Jan 2003 16:43:58 -0000	1.17
  +++ ConnectionPool.java	9 Jan 2003 13:33:51 -0000	1.18
  @@ -64,6 +64,8 @@
   import javax.sql.ConnectionPoolDataSource;
   import javax.sql.PooledConnection;
   
  +import org.apache.log4j.Category;
  +
   /**
    * This class implements a simple connection pooling scheme.  Multiple
    * pools are available through use of the <code>PoolBrokerService</code>.
  @@ -77,6 +79,7 @@
    * @author <a href="mailto:magnus@handtolvur.is">Magnús Þór Torfason</a>
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  + * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
    * @version $Id$
    */
   class ConnectionPool implements ConnectionEventListener
  @@ -122,6 +125,12 @@
        */
       private int waitCount = 0;
   
  +    /**
  +     * The logging category.
  +     */
  +    private static Category category
  +        = Category.getInstance(ConnectionPool.class.getName());
  +
       private int logInterval;
       private Monitor monitor;
   
  @@ -140,8 +149,6 @@
        */
       private Map timeStamps;
   
  -    private PrintWriter logWriter;
  -
       /**
        * Creates a <code>ConnectionPool</code> with the default
        * attributes.
  @@ -153,12 +160,10 @@
        * @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,
  -                   int connectionWaitTimeout, int logInterval,
  -                   PrintWriter logWriter)
  +                   int connectionWaitTimeout, int logInterval)
       {
           totalConnections = 0;
           pool = new Stack();
  @@ -192,7 +197,6 @@
               this.connectionWaitTimeout = 10 * 1000; // ten seconds
           }
           this.logInterval = logInterval * 1000;
  -        this.logWriter = logWriter;
   
           // Create monitor thread
           monitor = new Monitor();
  @@ -570,8 +574,8 @@
           }
           catch (Exception e)
           {
  -            log("[ERROR] Error occurred trying to close a PooledConnection."
  -                    + e.getMessage());
  +            category.error("Error occurred trying to close a "
  +                           + "PooledConnection.", e);
           }
           finally
           {
  @@ -579,18 +583,6 @@
           }
       }
   
  -    private void log(String s)
  -    {
  -        if (logWriter != null)
  -        {
  -            logWriter.println(s);
  -        }
  -        else
  -        {
  -            System.out.println(s);
  -        }
  -    }
  -
       ///////////////////////////////////////////////////////////////////////////
   
       /**
  @@ -619,7 +611,7 @@
                          .append(getNbrAvailable()).append(" + ")
                          .append(getNbrCheckedOut()).append(" = ")
                          .append(getTotalCount());
  -                log(buf.toString());
  +                category.info(buf.toString());
   
                   // Wait for a bit.
                   try
  
  
  
  1.6       +6 -2      jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java
  
  Index: TorqueClassicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TorqueClassicDataSource.java	26 Nov 2002 23:46:56 -0000	1.5
  +++ TorqueClassicDataSource.java	9 Jan 2003 13:33:51 -0000	1.6
  @@ -530,7 +530,7 @@
   
               ConnectionPool pool = new ConnectionPool(cpds, username, password,
                   maxConnections, maxExpiryTime, connectionWaitTimeout,
  -                logInterval, getLogWriter());
  +                logInterval);
   
               // avoid ConcurrentModificationException
               Map newPools = new HashMap(pools);
  @@ -550,6 +550,8 @@
   
       /**
        * Get the log writer for this data source.
  +     *
  +     * @deprecated Use correct debugging and logging code from Log4j
        */
       public PrintWriter getLogWriter()
       {
  @@ -571,6 +573,8 @@
   
       /**
        * Set the log writer for this data source.
  +     *
  +     * @deprecated Use correct debugging and logging code from Log4j
        */
       public void setLogWriter(java.io.PrintWriter out)
       {
  
  
  

Mime
View raw message