db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r420918 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java
Date Tue, 11 Jul 2006 16:39:15 GMT
Author: arminw
Date: Tue Jul 11 09:39:15 2006
New Revision: 420918

URL: http://svn.apache.org/viewvc?rev=420918&view=rev
Log:
add toString method, override finalze() to check for unclosed tx, javadoc cleanup

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java?rev=420918&r1=420917&r2=420918&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/TransactionImpl.java Tue
Jul 11 09:39:15 2006
@@ -24,6 +24,8 @@
 import java.util.List;
 
 import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.OJBRuntimeException;
 import org.apache.ojb.broker.PBFactoryException;
@@ -60,12 +62,7 @@
 /**
  * Implementation of Transaction for {@link org.odmg.Transaction}.
  *
- * @author     Thomas Mahler & David Dixon-Peugh
- * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
- * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
  * @version $Id$
- *
  */
 public class TransactionImpl
         implements Transaction, MaterializationListener, Configurable, CollectionProxyListener,
TransactionExt
@@ -1553,6 +1550,31 @@
         this.ordering = ordering;
     }
 
+    protected void finalize() throws Throwable
+    {
+        super.finalize();
+        if(isOpen())
+        {
+            log.error("Finalize object: This transaction is still marked as active, please
check code" +
+                    " for tx leaks: " + this.toString());
+            try
+            {
+                this.abort();
+            }
+            catch(Exception ignore)
+            {
+                // ignore
+            }
+        }
+    }
+
+    public String toString()
+    {
+        return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
+                .append("tx-status", TxUtil.getStatusString(getStatus()))
+                .append("unclosed_broker", this.broker != null && !broker.isClosed())
+                .toString();
+    }
 
     //============================================================
     // inner class



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


Mime
View raw message