diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-10-23 18:09:08 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-10-23 18:09:08 +0000 |
commit | f4b5012d20abe94c62e8d3b3c3d8ed626dff925b (patch) | |
tree | 7ed1c262d617a829dea07cef2964cb34e1f8e97d /src/main/java/com/amazon/carbonado/spi | |
parent | 81578d7b6798fe5b268d1227cf33d24897d5bdaa (diff) |
Deprecated use of ExceptionTransformer in TransactionManager.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/spi')
-rw-r--r-- | src/main/java/com/amazon/carbonado/spi/TransactionManager.java | 28 |
1 files changed, 24 insertions, 4 deletions
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<Txn> { 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<Txn> { 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<Txn> { *
* @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<Txn> implements Transaction {
private final TransactionManager<Txn> mTxnMgr;
@@ -393,9 +402,15 @@ public abstract class TransactionManager<Txn> { 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<Txn> { 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 {
|