db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1841141 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/util/ torque-test/src/test/java/org/apache/torque/util/
Date Mon, 17 Sep 2018 20:47:19 GMT
Author: tv
Date: Mon Sep 17 20:47:19 2018
New Revision: 1841141

URL: http://svn.apache.org/viewvc?rev=1841141&view=rev
Log:
Expose state tracking methods. Produces less casting and may be useful.

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnection.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnectionImpl.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TransactionManagerImpl.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnection.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnection.java?rev=1841141&r1=1841140&r2=1841141&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnection.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnection.java
Mon Sep 17 20:47:19 2018
@@ -32,4 +32,34 @@ public interface TorqueConnection extend
 {
     @Override
     void close() throws TorqueException;
+
+    /**
+     * Called by TransactionManagerImpl.commit() to track state
+     *
+     * @param committed the committed state to set
+     */
+    void setCommitted(boolean committed);
+
+    /**
+     * Has Transaction.commit() been called successfully on
+     * this connection?
+     *
+     * @return true, if Transaction.commit() has been called.
+     */
+    boolean isCommitted();
+
+    /**
+     * Called by TransactionManagerImpl.rollback() to track state
+     *
+     * @param rolledBack the rolledBack state to set
+     */
+    void setRolledBack(boolean rolledBack);
+
+    /**
+     * Has Transaction.rollback() been called successfully on
+     * this connection?
+     *
+     * @return true, if Transaction.rollback() has been called.
+     */
+    boolean isRolledBack();
 }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnectionImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnectionImpl.java?rev=1841141&r1=1841140&r2=1841141&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnectionImpl.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TorqueConnectionImpl.java
Mon Sep 17 20:47:19 2018
@@ -72,7 +72,8 @@ public class TorqueConnectionImpl implem
      *
      * @param committed the committed state to set
      */
-    protected void setCommitted(boolean committed)
+    @Override
+    public void setCommitted(boolean committed)
     {
         this.committed = committed;
     }
@@ -83,7 +84,8 @@ public class TorqueConnectionImpl implem
      *
      * @return true, if Transaction.commit() has been called.
      */
-    protected boolean isCommitted()
+    @Override
+    public boolean isCommitted()
     {
         return committed;
     }
@@ -93,7 +95,8 @@ public class TorqueConnectionImpl implem
      *
      * @param rolledBack the rolledBack state to set
      */
-    protected void setRolledBack(boolean rolledBack)
+    @Override
+    public void setRolledBack(boolean rolledBack)
     {
         this.rolledBack = rolledBack;
     }
@@ -104,7 +107,8 @@ public class TorqueConnectionImpl implem
      *
      * @return true, if Transaction.rollback() has been called.
      */
-    protected boolean isRolledBack()
+    @Override
+    public boolean isRolledBack()
     {
         return rolledBack;
     }
@@ -210,7 +214,7 @@ public class TorqueConnectionImpl implem
             if (!isCommitted())
             {
                 // calls close on the connection
-                Transaction.safeRollback(connection);
+                Transaction.rollback(connection);
             }
 
             // Justin Case

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TransactionManagerImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TransactionManagerImpl.java?rev=1841141&r1=1841140&r2=1841141&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TransactionManagerImpl.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/TransactionManagerImpl.java
Mon Sep 17 20:47:19 2018
@@ -106,9 +106,9 @@ public class TransactionManagerImpl impl
             {
                 con.commit();
 
-                if (con instanceof TorqueConnectionImpl)
+                if (con instanceof TorqueConnection)
                 {
-                    ((TorqueConnectionImpl) con).setCommitted(true);
+                    ((TorqueConnection) con).setCommitted(true);
                 }
             }
         }
@@ -151,9 +151,9 @@ public class TransactionManagerImpl impl
                 {
                     con.rollback();
 
-                    if (con instanceof TorqueConnectionImpl)
+                    if (con instanceof TorqueConnection)
                     {
-                        ((TorqueConnectionImpl) con).setRolledBack(true);
+                        ((TorqueConnection) con).setRolledBack(true);
                     }
                 }
             }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java?rev=1841141&r1=1841140&r2=1841141&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java
(original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/TorqueConnectionImplTest.java
Mon Sep 17 20:47:19 2018
@@ -46,9 +46,7 @@ public class TorqueConnectionImplTest ex
             BookPeer.doSelect(new Criteria(), con);
             Transaction.commit(con);
 
-            @SuppressWarnings("resource")
-            TorqueConnectionImpl conImpl = (TorqueConnectionImpl)con;
-            assertTrue(conImpl.isCommitted());
+            assertTrue(con.isCommitted());
         }
         catch (TorqueException e)
         {



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


Mime
View raw message