From a786db8ab53c879858268da6a0cbe4ba9956d160 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 4 Feb 2008 05:42:54 +0000 Subject: Make TransactionManager creation more flexible. --- .../amazon/carbonado/spi/AbstractRepository.java | 28 +++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/spi') diff --git a/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java b/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java index c9bc0b5..191f94e 100644 --- a/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java +++ b/src/main/java/com/amazon/carbonado/spi/AbstractRepository.java @@ -54,7 +54,6 @@ public abstract class AbstractRepository implements Repository, ShutdownCapability, SequenceCapability { private final String mName; - private final TransactionManager mTxnMgr; private final ReadWriteLock mShutdownLock; private final StoragePool mStoragePool; @@ -97,8 +96,6 @@ public abstract class AbstractRepository } } }; - - mTxnMgr = createTransactionManager(); } public String getName() { @@ -112,19 +109,19 @@ public abstract class AbstractRepository } public Transaction enterTransaction() { - return mTxnMgr.localScope().enter(null); + return localTransactionScope().enter(null); } public Transaction enterTransaction(IsolationLevel level) { - return mTxnMgr.localScope().enter(level); + return localTransactionScope().enter(level); } public Transaction enterTopTransaction(IsolationLevel level) { - return mTxnMgr.localScope().enterTop(level); + return localTransactionScope().enterTop(level); } public IsolationLevel getTransactionIsolationLevel() { - return mTxnMgr.localScope().getIsolationLevel(); + return localTransactionScope().getIsolationLevel(); } /** @@ -207,18 +204,14 @@ public abstract class AbstractRepository } /** - * Returns the TransactionManager which was passed into the constructor. + * Returns the repository's TransactionManager. */ - protected TransactionManager transactionManager() { - return mTxnMgr; - } + protected abstract TransactionManager transactionManager(); /** * Returns the thread-local TransactionScope, creating it if needed. */ - protected TransactionScope localTransactionScope() { - return mTxnMgr.localScope(); - } + protected abstract TransactionScope localTransactionScope(); /** * Call to prevent shutdown hook from running. Be sure to call @@ -281,11 +274,6 @@ public abstract class AbstractRepository protected abstract SequenceValueProducer createSequenceValueProducer(String name) throws RepositoryException; - /** - * Called upon to create a new TransactionManager instance. - */ - protected abstract TransactionManager createTransactionManager(); - void info(String message) { Log log = getLog(); if (log != null) { @@ -337,7 +325,7 @@ public abstract class AbstractRepository repository.mSequencePool.returnReservedValues(null); try { - repository.mTxnMgr.close(suspendThreads); + repository.transactionManager().close(suspendThreads); } catch (Throwable e) { repository.error("Failed to close TransactionManager", e); } -- cgit v1.2.3