summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2010-01-18 19:06:09 +0000
committerBrian S. O'Neill <bronee@gmail.com>2010-01-18 19:06:09 +0000
commit3baee4ce35e6ae0afc0581809d8ca8c66a170e20 (patch)
tree14e25c4ba7fd8f76c795e3d76c6029457c0173bd /src/main/java/com/amazon/carbonado/txn/TransactionManager.java
parentc3d44c4637c4b7eafe95dc0352f0345b7447a3d0 (diff)
Add attach/detach notification.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/txn/TransactionManager.java')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionManager.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
index 0f203aa..45a2028 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java
@@ -80,6 +80,7 @@ public abstract class TransactionManager<Txn> {
TransactionScope<Txn> scope = mLocalScope.get();
if (scope != null) {
scope.markDetached();
+ detachNotification(scope.getActiveTxn());
mLocalScope.remove();
}
return scope;
@@ -89,6 +90,7 @@ public abstract class TransactionManager<Txn> {
boolean removeLocalScope(TransactionScope<Txn> scope) {
TransactionScope<Txn> existing = mLocalScope.get();
if (existing == scope) {
+ detachNotification(scope.getActiveTxn());
mLocalScope.remove();
return true;
}
@@ -99,6 +101,7 @@ public abstract class TransactionManager<Txn> {
boolean setLocalScope(TransactionScope<Txn> scope, boolean detached) {
TransactionScope<Txn> existing = mLocalScope.get();
if (((existing == null || existing.isInactive()) && detached) || existing == scope) {
+ attachNotification(scope.getActiveTxn());
mLocalScope.set(scope);
return true;
}
@@ -213,6 +216,28 @@ public abstract class TransactionManager<Txn> {
}
/**
+ * Called to notify internal method that transaction is attached.
+ * The default implementation of this method does nothing. Override if
+ * using remote transactions.
+ *
+ * @param txn transaction that is attached, could be null if none exists
+ * @since 1.2.2
+ */
+ protected void attachNotification(Txn txn) {
+ }
+
+ /**
+ * Called to notify internal method that transaction is detached.
+ * The default implementation of this method does nothing. Override if
+ * using remote transactions.
+ *
+ * @param txn transaction that is dettached, could be null if none exists
+ * @since 1.2.2
+ */
+ protected void detachNotification(Txn txn) {
+ }
+
+ /**
* Commits and closes the given internal transaction.
*
* @return true if transaction object is still valid