db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r220088 - in /incubator/jdo/trunk/runtime20/src/java/org/apache/jdo: impl/state/StateManagerImpl.java state/StateManagerInternal.java
Date Thu, 21 Jul 2005 14:19:47 GMT
Author: mbo
Date: Thu Jul 21 07:19:45 2005
New Revision: 220088

URL: http://svn.apache.org/viewcvs?rev=220088&view=rev
Log:
Added StateManager method isBeforeImageRequired

Modified:
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java
    incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java?rev=220088&r1=220087&r2=220088&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java
(original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java
Thu Jul 21 07:19:45 2005
@@ -679,6 +679,20 @@
         return myLC.isNew();
     }
 
+    /**
+     * Returns <code>true</code>, if a before image must be created. The
+     * decision is based on the current lifecycle state plus other conditions
+     * e.g. transaction type, restore values flag, etc.
+     * @see org.apache.jdo.state.StateManagerInternal#isBeforeImageRequired()
+     * @return <code>true</code> if a before image must be created.
+     */
+    public boolean isBeforeImageRequired() {
+        boolean isTransientTransactional = 
+            !myLC.isPersistent() && myLC.isTransactional();
+        return (tx.getOptimistic() || tx.getRestoreValues() ||
+                isTransientTransactional);
+    }
+
     //
     // LifeCycleState transition requests
     //
@@ -936,11 +950,8 @@
             debug("createBeforeImage: new " + (beforeImage == null) + // NOI18N
                 " Tx is active: " + tx.isActive()); // NOI18N
 
-        boolean isTransientTransactional = 
-            !myLC.isPersistent() && myLC.isTransactional();
-        if (beforeImage == null && tx.isActive() && 
-            (tx.getOptimistic() || tx.getRestoreValues() || 
-             isTransientTransactional)) {
+        if (beforeImage == null && tx.isActive() &&
+            isBeforeImageRequired()) {
 
             beforeImage = jdoImplHelper.newInstance (myPCClass, this);
             int[] fields = getFieldNums(loadedFields);
@@ -1349,11 +1360,7 @@
         if (debugging())
             debug("createBeforeImage"); // NOI18N
 
-        boolean isTransientTransactional = 
-            !myLC.isPersistent() && myLC.isTransactional();
-        if (tx.getOptimistic() || tx.getRestoreValues() ||
-            isTransientTransactional) {
-
+        if (isBeforeImageRequired()) {
             beforeImage = jdoImplHelper.newInstance (myPCClass, this);
             beforeImage.jdoCopyFields(myPC, getFieldNums(loadedFields));
             biFields.or(loadedFields);

Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java?rev=220088&r1=220087&r2=220088&view=diff
==============================================================================
--- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java
(original)
+++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java
Thu Jul 21 07:19:45 2005
@@ -272,4 +272,12 @@
      */
     public boolean isNew();
 
+    /**
+     * Returns <code>true</code>, if a before image must be created. The
+     * decision is based on the current lifecycle state plus other conditions
+     * e.g. transaction type, restore values flag, etc.
+     * @return <code>true</code> if a before image must be created.
+     */
+    public boolean isBeforeImageRequired();
+    
 }



Mime
View raw message