diff options
Diffstat (limited to 'src/main/java/com/amazon')
8 files changed, 35 insertions, 13 deletions
diff --git a/src/main/java/com/amazon/carbonado/Cursor.java b/src/main/java/com/amazon/carbonado/Cursor.java index c7e4404..2740611 100644 --- a/src/main/java/com/amazon/carbonado/Cursor.java +++ b/src/main/java/com/amazon/carbonado/Cursor.java @@ -48,11 +48,12 @@ import java.util.NoSuchElementException; * @author Brian S O'Neill
* @author Don Schneider
*/
-public interface Cursor<S> {
+public interface Cursor<S> extends AutoCloseable {
/**
* Call close to release any resources being held by this cursor. Further
* operations on this cursor will behave as if there are no results.
*/
+ @Override
void close() throws FetchException;
/**
diff --git a/src/main/java/com/amazon/carbonado/Transaction.java b/src/main/java/com/amazon/carbonado/Transaction.java index 876c7be..6d4a9d9 100644 --- a/src/main/java/com/amazon/carbonado/Transaction.java +++ b/src/main/java/com/amazon/carbonado/Transaction.java @@ -61,7 +61,7 @@ import java.util.concurrent.TimeUnit; *
* @author Brian S O'Neill
*/
-public interface Transaction {
+public interface Transaction extends AutoCloseable {
/**
* If currently in a transaction, commits all changes to the storage layer
* since the last commit within the transaction.
@@ -159,4 +159,10 @@ public interface Transaction { * @return false if transaction has exited
*/
boolean preCommit() throws PersistException;
+
+ /**
+ * Calls {@link #exit exit}, for compatibility with AutoCloseable.
+ * @throws PersistException
+ */
+ void close() throws PersistException;
}
diff --git a/src/main/java/com/amazon/carbonado/repo/logging/LoggingTransaction.java b/src/main/java/com/amazon/carbonado/repo/logging/LoggingTransaction.java index e2b080c..5141d6e 100644 --- a/src/main/java/com/amazon/carbonado/repo/logging/LoggingTransaction.java +++ b/src/main/java/com/amazon/carbonado/repo/logging/LoggingTransaction.java @@ -102,6 +102,11 @@ class LoggingTransaction implements Transaction { return mTxn.preCommit();
}
+ @Override
+ public void close() throws PersistException {
+ exit();
+ }
+
private String idChain() {
if (mParent == null) {
return String.valueOf(mID);
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReadOnlyTransaction.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReadOnlyTransaction.java index 1666bf4..d3649ba 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReadOnlyTransaction.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReadOnlyTransaction.java @@ -25,7 +25,7 @@ import com.amazon.carbonado.PersistException; import com.amazon.carbonado.Transaction; /** - * ReadOnlyTransaction wraps an another transaction. It's only function is to + * ReadOnlyTransaction wraps an another transaction. Its only function is to * serve as a marker for the ReplicatedStorage triggers that no write * operations are allowed. * @@ -87,5 +87,10 @@ class ReadOnlyTransaction implements Transaction { public String toString() { return "ReadOnlyTransaction wrapping { " + mTxn.toString() + " }"; } + + @Override + public void close() throws PersistException { + exit(); + } } diff --git a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java index 9463785..3d9aaa4 100644 --- a/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java +++ b/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java @@ -422,12 +422,7 @@ public class SyntheticStorableBuilder }
/**
- * @param annotator
- * source of annotation (eg, makeAnnotation and makeMemberValue)
- * @param indexes
- * @param position
- * @param annotationClass TODO
- * @return
+ * @param annotator source of annotation (eg, makeAnnotation and makeMemberValue)
*/
private Annotation addIndex(Annotation annotator,
Annotation.MemberValue[] indexes,
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionPair.java b/src/main/java/com/amazon/carbonado/txn/TransactionPair.java index f719a79..e247661 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionPair.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionPair.java @@ -110,4 +110,9 @@ public class TransactionPair implements Transaction { public boolean preCommit() throws PersistException {
return mPrimaryTransaction.preCommit() ? mSecondaryTransaction.preCommit() : false;
}
+
+ @Override
+ public void close() throws PersistException {
+ exit();
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index 6e94b91..6061c62 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -216,7 +216,7 @@ public class TransactionScope<Txn> { mLock.unlock();
}
}
-
+
/**
* Returns the implementation for the active transaction, only if it exists.
* (does not create a transaction like getTxn()
@@ -323,10 +323,10 @@ public class TransactionScope<Txn> { mLock.unlock();
return;
}
-
+
Map<Class<?>, CursorList<TransactionImpl<Txn>>> cursors;
try {
- cursors = mCursors;
+ cursors = mCursors;
// Ensure that map is freed promptly. Thread-local reference to
// this scope otherwise keeps map and its contents lingering around
@@ -427,6 +427,11 @@ public class TransactionScope<Txn> { }
}
+ @Override
+ public void close() throws PersistException {
+ exit();
+ }
+
public void commit() throws PersistException {
TransactionScope<Txn> scope = mScope;
scope.mLock.lock();
diff --git a/src/main/java/com/amazon/carbonado/util/BelatedCreationException.java b/src/main/java/com/amazon/carbonado/util/BelatedCreationException.java index 117cc5a..d3863ec 100644 --- a/src/main/java/com/amazon/carbonado/util/BelatedCreationException.java +++ b/src/main/java/com/amazon/carbonado/util/BelatedCreationException.java @@ -22,7 +22,7 @@ package com.amazon.carbonado.util; * Exception throw when attempting to perform an unavailable operation on an * object undergoing belated creation. * - * @see com.amazon.carbonado.util.BelatedCreator; + * @see BelatedCreator * * @author Jesse Morgan (morganjm) */ |