summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-10-23 20:41:25 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-10-23 20:41:25 +0000
commitf73f19bf0661afb489e0c17a2d987257865003dc (patch)
tree8ec4dbb9af0d7c0eefe535801c59fa83de3df2a6
parent0ae886697e09bd010dfdf730843dfa04f453e63b (diff)
Allow transaction implementation to be notified when update mode is selected.
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionManager.java10
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java9
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
index 4914be9..528ade5 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
@@ -199,6 +199,16 @@ public abstract class TransactionManager<Txn> {
}
/**
+ * Called when the Transaction.setForUpdate method is called. The default
+ * implementation of this method does nothing. Override if internal
+ * transaction needs to switch modes.
+ *
+ * @since 1.2.1
+ */
+ protected void setForUpdate(Txn txn, boolean forUpdate) {
+ }
+
+ /**
* Commits and closes the given internal transaction.
*
* @return true if transaction object is still valid
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
index 1e294e4..29c173c 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
@@ -408,7 +408,11 @@ public class TransactionScope<Txn> {
}
public void setForUpdate(boolean forUpdate) {
- mForUpdate = forUpdate && mScope.mTxnMgr.supportsForUpdate();
+ mForUpdate = (forUpdate &= mScope.mTxnMgr.supportsForUpdate());
+ Txn txn = mTxn;
+ if (txn != null) {
+ mScope.mTxnMgr.setForUpdate(txn, forUpdate);
+ }
}
public boolean isForUpdate() {
@@ -472,6 +476,9 @@ public class TransactionScope<Txn> {
mDesiredLockTimeout, mTimeoutUnit);
}
}
+ if (mForUpdate) {
+ scope.mTxnMgr.setForUpdate(mTxn, true);
+ }
return mTxn;
}