commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1547338 - in /commons/proper/dbcp/trunk/src: changes/changes.xml java/org/apache/commons/dbcp2/BasicDataSource.java
Date Tue, 03 Dec 2013 10:36:55 GMT
Author: markt
Date: Tue Dec  3 10:36:54 2013
New Revision: 1547338

URL: http://svn.apache.org/r1547338
Log:
Fix DBCP-396
Expose all of the AbandonedConfig properties through a BasicDataSource.

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1547338&r1=1547337&r2=1547338&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Tue Dec  3 10:36:54 2013
@@ -93,6 +93,9 @@ The <action> type attribute can be add,u
         Use one line per statement for methods with multiple statements rather
         than using a single line.
       </action>
+      <action dev="markt" issue="DBCP-396" type="fix">
+        Expose all of the AbandonedConfig properties through a BasicDataSource.
+      </action>
     </release>
     <release version="1.4.1" date="TBD" description="TBD">
       <action dev="psteitz" issue="DBCP-334" type="update" due-to="Alberto Mozzone">

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1547338&r1=1547337&r2=1547338&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java Tue Dec
 3 10:36:54 2013
@@ -36,6 +36,7 @@ import javax.sql.DataSource;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.UsageTracking;
 import org.apache.commons.pool2.impl.AbandonedConfig;
 import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
 import org.apache.commons.pool2.impl.GenericObjectPool;
@@ -1507,6 +1508,64 @@ public class BasicDataSource implements 
         this.restartNeeded = true;
     }
 
+    /**
+     * Gets the log writer to be used by this configuration to log
+     * information on abandoned objects.
+     */
+    public PrintWriter getAbandonedLogWriter() {
+        if (abandonedConfig != null) {
+            return abandonedConfig.getLogWriter();
+        }
+        return null;
+    }
+    
+    /**
+     * Sets the log writer to be used by this configuration to log
+     * information on abandoned objects.
+     *
+     * @param logWriter The new log writer
+     */
+    public void setAbandonedLogWriter(PrintWriter logWriter) {
+        if (abandonedConfig == null) {
+            abandonedConfig = new AbandonedConfig();
+        }
+        abandonedConfig.setLogWriter(logWriter);
+        this.restartNeeded = true;
+    }
+    
+    /**
+     * If the connection pool implements {@link UsageTracking}, should the
+     * connection pool record a stack trace every time a method is called on a
+     * pooled connection and retain the most recent stack trace to aid debugging
+     * of abandoned connections?
+     *
+     * @return <code>true</code> if usage tracking is enabled
+     */
+    public boolean getAbandonedUsageTracking() {
+        if (abandonedConfig != null) {
+            return abandonedConfig.getUseUsageTracking();
+        }
+        return false;
+    }
+    
+    /**
+     * If the connection pool implements {@link UsageTracking}, configure
+     * whether the connection pool should record a stack trace every time a
+     * method is called on a pooled connection and retain the most recent stack
+     * trace to aid debugging of abandoned connections.
+     *
+     * @param   usageTracking    A value of <code>true</code> will enable
+     *                              the recording of a stack trace on every use
+     *                              of a pooled connection
+     */
+    public void setAbandonedUsageTracking(boolean usageTracking) {
+        if (abandonedConfig == null) {
+            abandonedConfig = new AbandonedConfig();
+        }
+        abandonedConfig.setUseUsageTracking(usageTracking);
+        this.restartNeeded = true;
+    }
+    
     // --------------------------------------------------------- Public Methods
 
     /**



Mime
View raw message