From f4b5012d20abe94c62e8d3b3c3d8ed626dff925b Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 23 Oct 2007 18:09:08 +0000 Subject: Deprecated use of ExceptionTransformer in TransactionManager. --- .../amazon/carbonado/spi/TransactionManager.java | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/spi') diff --git a/src/main/java/com/amazon/carbonado/spi/TransactionManager.java b/src/main/java/com/amazon/carbonado/spi/TransactionManager.java index 355af7c..676a15d 100644 --- a/src/main/java/com/amazon/carbonado/spi/TransactionManager.java +++ b/src/main/java/com/amazon/carbonado/spi/TransactionManager.java @@ -50,6 +50,9 @@ public abstract class TransactionManager { private boolean mClosed; + /** + * @deprecated + */ public TransactionManager(ExceptionTransformer exTransformer) { // The use of a fair lock is essential for shutdown hooks that attempt // to acquire the locks of all TransactionManagers. Otherwise, the @@ -58,8 +61,14 @@ public abstract class TransactionManager { mExTransformer = exTransformer; } + public TransactionManager() { + this(null); + } + /** * Returns the exception transformer in use. + * + * @deprecated */ public ExceptionTransformer getExceptionTransformer() { return mExTransformer; @@ -337,12 +346,12 @@ public abstract class TransactionManager { * * @return true if transaction object is still valid */ - protected abstract boolean commitTxn(Txn txn) throws Exception; + protected abstract boolean commitTxn(Txn txn) throws PersistException; /** * Aborts and closes the given internal transaction. */ - protected abstract void abortTxn(Txn txn) throws Exception; + protected abstract void abortTxn(Txn txn) throws PersistException; private static class TransactionImpl implements Transaction { private final TransactionManager mTxnMgr; @@ -393,9 +402,15 @@ public abstract class TransactionManager { if (!txnMgr.commitTxn(mTxn)) { mTxn = null; } + } catch (PersistException e) { + mTxn = null; + throw e; } catch (Throwable e) { mTxn = null; - throw txnMgr.mExTransformer.toPersistException(e); + if (txnMgr.mExTransformer != null) { + throw txnMgr.mExTransformer.toPersistException(e); + } + throw new PersistException(e); } } else { // Indicate fake nested transaction committed. @@ -424,8 +439,13 @@ public abstract class TransactionManager { if (mParent == null || mParent.mTxn != mTxn) { try { txnMgr.abortTxn(mTxn); + } catch (PersistException e) { + throw e; } catch (Throwable e) { - throw txnMgr.mExTransformer.toPersistException(e); + if (txnMgr.mExTransformer != null) { + throw txnMgr.mExTransformer.toPersistException(e); + } + throw new PersistException(e); } } } finally { -- cgit v1.2.3