Interface Transaction
- 
- All Superinterfaces:
- AutoCloseable
 - All Known Implementing Classes:
- AbstractThreadedTransaction,- AbstractThreadLocalTransaction,- AbstractTransaction,- DriverRemoteTransaction
 
 public interface Transaction extends AutoCloseable A set of methods that allow for control of transactional behavior of aGraphinstance. Providers may consider usingAbstractTransactionas a base implementation that provides default features for most of these methods.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com), TinkerPop Community (http://tinkerpop.apache.org)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classTransaction.CLOSE_BEHAVIORBehaviors to supply to theonClose(Consumer).static classTransaction.Exceptionsstatic classTransaction.READ_WRITE_BEHAVIORBehaviors to supply to theonReadWrite(Consumer).static classTransaction.StatusA status provided to transaction listeners to inform whether a transaction was successfully committed or rolled back.
 - 
Field SummaryFields Modifier and Type Field Description static TransactionNO_OP
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddTransactionListener(Consumer<Transaction.Status> listener)Adds a listener that is called back with a status when a commit or rollback is successful.default <T extends TraversalSource>
 Tbegin()Starts a transaction in the context of aGraphTraversalSourceinstance.<T extends TraversalSource>
 Tbegin(Class<T> traversalSourceClass)Starts a transaction in the context of a particularTraversalSourceinstance.voidclearTransactionListeners()Removes all transaction listeners.voidclose()Closes the transaction where the default close behavior defined by {onClose(Consumer)} will be executed.voidcommit()Commits a transaction.default <G extends Graph>
 GcreateThreadedTx()Creates a transaction that can be executed across multiple threads.booleanisOpen()Determines if a transaction is currently open.TransactiononClose(Consumer<Transaction> consumer)Describes what happens to a transaction on a call toGraph.close().TransactiononReadWrite(Consumer<Transaction> consumer)Describes how a transaction is started when a read or a write occurs.voidopen()Opens a transaction.voidreadWrite()An internal function that signals a read or a write has occurred - not meant to be called directly by end users.voidremoveTransactionListener(Consumer<Transaction.Status> listener)Removes a transaction listener.voidrollback()Rolls back a transaction.
 
- 
- 
- 
Field Detail- 
NO_OPstatic final Transaction NO_OP 
 
- 
 - 
Method Detail- 
openvoid open() Opens a transaction.
 - 
commitvoid commit() Commits a transaction. This method may optionally throwTransactionExceptionon error. Providers should consider wrapping their transaction exceptions in this TinkerPop exception as it will lead to better error handling with Gremlin Server and other parts of the stack.
 - 
rollbackvoid rollback() Rolls back a transaction. This method may optionally throwTransactionExceptionon error. Providers should consider wrapping their transaction exceptions in this TinkerPop exception as it will lead to better error handling with Gremlin Server and other parts of the stack.
 - 
createThreadedTxdefault <G extends Graph> G createThreadedTx() Creates a transaction that can be executed across multiple threads. TheGraphreturned from this method is not meant to represent some form of child transaction that can be committed from this object. A threaded transaction is aGraphinstance that has a transaction context that enables multiple threads to collaborate on the same transaction. A standard transactional context tied to aGraphthat supports transactions will typically bind a transaction to a single thread viaThreadLocal.
 - 
begindefault <T extends TraversalSource> T begin() Starts a transaction in the context of aGraphTraversalSourceinstance. It is up to theTransactionimplementation to decide what this means and up to users to be aware of that meaning.
 - 
begin<T extends TraversalSource> T begin(Class<T> traversalSourceClass) Starts a transaction in the context of a particularTraversalSourceinstance. It is up to theTransactionimplementation to decide what this means and up to users to be aware of that meaning.
 - 
isOpenboolean isOpen() Determines if a transaction is currently open.
 - 
readWritevoid readWrite() An internal function that signals a read or a write has occurred - not meant to be called directly by end users.
 - 
closevoid close() Closes the transaction where the default close behavior defined by {onClose(Consumer)} will be executed.- Specified by:
- closein interface- AutoCloseable
 
 - 
onReadWriteTransaction onReadWrite(Consumer<Transaction> consumer) Describes how a transaction is started when a read or a write occurs. This value can be set using standard behaviors defined inTransaction.READ_WRITE_BEHAVIORor a mapperConsumerfunction.
 - 
onCloseTransaction onClose(Consumer<Transaction> consumer) Describes what happens to a transaction on a call toGraph.close(). This value can be set using standard behavior defined inTransaction.CLOSE_BEHAVIORor a mapperConsumerfunction.
 - 
addTransactionListenervoid addTransactionListener(Consumer<Transaction.Status> listener) Adds a listener that is called back with a status when a commit or rollback is successful. It is expected that listeners be bound to the current thread as is standard for transactions. Therefore a listener registered in the current thread will not get callback events from a commit or rollback call in a different thread.
 - 
removeTransactionListenervoid removeTransactionListener(Consumer<Transaction.Status> listener) Removes a transaction listener.
 - 
clearTransactionListenersvoid clearTransactionListeners() Removes all transaction listeners.
 
- 
 
-