commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r482015 - in /jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp: AbandonedConfig.java AbandonedObjectPool.java AbandonedTrace.java
Date Mon, 04 Dec 2006 02:22:10 GMT
Author: psteitz
Date: Sun Dec  3 18:22:09 2006
New Revision: 482015

URL: http://svn.apache.org/viewvc?view=rev&rev=482015
Log:
Javadoc and formatting only.

Modified:
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java?view=diff&rev=482015&r1=482014&r2=482015
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java
Sun Dec  3 18:22:09 2006
@@ -26,6 +26,10 @@
  */
 public class AbandonedConfig {
 
+    /**
+     * Whether or not a connection is considered abandoned and eligible
+     * for removal if it has been idle longer than the removeAbandonedTimeout
+     */
     private boolean removeAbandoned = false;
 
     /**
@@ -61,6 +65,9 @@
         this.removeAbandoned = removeAbandoned;
     }
 
+    /**
+     * Timeout in seconds before an abandoned connection can be removed
+     */
     private int removeAbandonedTimeout = 300;
 
     /**
@@ -85,6 +92,10 @@
         this.removeAbandonedTimeout = removeAbandonedTimeout;
     }
 
+    /**
+     * Determines whether or not to log stack traces for application code
+     * which abandoned a Statement or Connection.
+     */
     private boolean logAbandoned = false;
 
     /**
@@ -112,6 +123,7 @@
      * Logging of abandoned Statements and Connections adds overhead
      * for every Connection open or new Statement because a stack
      * trace has to be generated.
+     * @param logAbandoned true turns on abandoned stack trace logging
      *
      */
     public void setLogAbandoned(boolean logAbandoned) {

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java?view=diff&rev=482015&r1=482014&r2=482015
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedObjectPool.java
Sun Dec  3 18:22:09 2006
@@ -36,9 +36,14 @@
  */
 public class AbandonedObjectPool extends GenericObjectPool {
 
-    // DBCP AbandonedConfig
+    /** 
+     * DBCP AbandonedConfig 
+     */
     private AbandonedConfig config = null;
-    // A list of connections in use
+    
+    /**
+     * A list of connections in use
+     */
     private List trace = new ArrayList();
 
     /**
@@ -66,6 +71,8 @@
      * getNumIdle() < 2
      * 
      * @return Object jdbc Connection
+     * @throws Exception if an exception occurs retrieving a 
+     * connection from the pool
      */
     public Object borrowObject() throws Exception {
         if (config != null
@@ -75,11 +82,11 @@
             removeAbandoned();
         }
         Object obj = super.borrowObject();
-        if(obj instanceof AbandonedTrace) {
-            ((AbandonedTrace)obj).setStackTrace();
+        if (obj instanceof AbandonedTrace) {
+            ((AbandonedTrace) obj).setStackTrace();
         }
         if (obj != null && config != null && config.getRemoveAbandoned())
{
-            synchronized(trace) {
+            synchronized (trace) {
                 trace.add(obj);
             }
         }
@@ -90,10 +97,12 @@
      * Return a db connection to the pool.
      *
      * @param obj db Connection to return
+     * @throws Exception if an exception occurs returning the connection
+     * to the pool
      */
     public void returnObject(Object obj) throws Exception {
         if (config != null && config.getRemoveAbandoned()) {
-            synchronized(trace) {
+            synchronized (trace) {
                 boolean foundObject = trace.remove(obj);
                 if (!foundObject) {
                     return; // This connection has already been invalidated.  Stop now.
@@ -103,9 +112,15 @@
         super.returnObject(obj);
     }
 
+    /**
+     * Invalidates an object from the pool.
+     *
+     * @param obj object to be returned
+     * @throws Exception if an exception occurs invalidating the object
+     */
     public void invalidateObject(Object obj) throws Exception {
         if (config != null && config.getRemoveAbandoned()) {
-            synchronized(trace) {
+            synchronized (trace) {
                 boolean foundObject = trace.remove(obj);
                 if (!foundObject) {
                     return; // This connection has already been invalidated.  Stop now.
@@ -124,10 +139,10 @@
         long now = System.currentTimeMillis();
         long timeout = now - (config.getRemoveAbandonedTimeout() * 1000);
         ArrayList remove = new ArrayList();
-        synchronized(trace) {
+        synchronized (trace) {
             Iterator it = trace.iterator();
             while (it.hasNext()) {
-                AbandonedTrace pc = (AbandonedTrace)it.next();
+                AbandonedTrace pc = (AbandonedTrace) it.next();
                 if (pc.getLastUsed() > timeout) {
                     continue;
                 }
@@ -140,15 +155,17 @@
         // Now remove the abandoned connections
         Iterator it = remove.iterator();
         while (it.hasNext()) {
-            AbandonedTrace pc = (AbandonedTrace)it.next();
+            AbandonedTrace pc = (AbandonedTrace) it.next();
             if (config.getLogAbandoned()) {
                 pc.printStackTrace();
             }             
             try {
                 invalidateObject(pc);
-            } catch(Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
-            }             
+            }
+            
         }
     }
 }
+

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java?view=diff&rev=482015&r1=482014&r2=482015
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java
Sun Dec  3 18:22:09 2006
@@ -36,20 +36,22 @@
  */
 public class AbandonedTrace {
 
+    /** Date format */
     private static SimpleDateFormat format = new SimpleDateFormat
         ("'DBCP object created' yyyy-MM-dd HH:mm:ss " +
          "'by the following code was never closed:'");
 
-    // DBCP AbandonedConfig
+    /** DBCP AbandonedConfig */
     private AbandonedConfig config = null;
-    // Parent object
+    /**  Parent object */
     private AbandonedTrace parent;
-    // A stack trace of the code that created me (if in debug mode) **/
+    /** A stack trace of the code that created me (if in debug mode) */
     private Exception createdBy;
+    /** Time created */
     private long createdTime;
-    // A list of objects created by children of this object
+    /** A list of objects created by children of this object */
     private List trace = new ArrayList();
-    // Last time this connection was used
+    /** Last time this connection was used */
     private long lastUsed = 0;
 
     /**
@@ -170,7 +172,7 @@
      * @param trace AbandonedTrace object to add
      */
     protected void addTrace(AbandonedTrace trace) {
-        synchronized(this) {
+        synchronized (this) {
             this.trace.add(trace);
         }
         setLastUsed();



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


Mime
View raw message