From 4684549782accd0ffba1aefd15d42918effeddfd Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 22 Dec 2009 01:15:07 +0000 Subject: Added isClosed method to Repository. --- src/main/java/com/amazon/carbonado/txn/TransactionManager.java | 4 ++++ src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'src/main/java/com/amazon/carbonado/txn') diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java index 36d2e22..0f203aa 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java @@ -134,6 +134,10 @@ public abstract class TransactionManager { } } + public synchronized boolean isClosed() { + return mState != OPEN; + } + /** * Returns supported isolation level, which may be higher. If isolation * level cannot go higher (or lower than parent) then return null. diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index bce8ca6..4def72d 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -57,6 +57,14 @@ public class TransactionScope { TransactionScope(TransactionManager txnMgr, boolean closed) { mTxnMgr = txnMgr; mLock = new ReentrantLock(true); + if (closed) { + mLock.lock(); + try { + mClosed = true; + } finally { + mLock.unlock(); + } + } } /** -- cgit v1.2.3