Class AbstractThreadedTransaction
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction
- 
- org.apache.tinkerpop.gremlin.structure.util.AbstractThreadedTransaction
 
 
- 
- All Implemented Interfaces:
- AutoCloseable,- Transaction
 
 public abstract class AbstractThreadedTransaction extends AbstractTransaction A base implementation ofTransactionthat provides core functionality for transaction listeners using a shared set of transaction listeners. Therefore, whenAbstractTransaction.commit()is called from any thread, all listeners get notified. This implementation would be useful for graph implementations that support threaded transactions, specifically in theGraphinstance returned fromTransaction.createThreadedTx().- Author:
- Stephen Mallette (http://stephen.genoprime.com)
- See Also:
- AbstractThreadLocalTransaction
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.TransactionTransaction.CLOSE_BEHAVIOR, Transaction.Exceptions, Transaction.READ_WRITE_BEHAVIOR, Transaction.Status, Transaction.Symbols
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected List<Consumer<Transaction.Status>>transactionListeners- 
Fields inherited from interface org.apache.tinkerpop.gremlin.structure.TransactionNO_OP
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractThreadedTransaction(Graph g)
 - 
Method SummaryAll Methods Instance Methods Concrete 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.voidclearTransactionListeners()Removes all transaction listeners.protected voiddoClose()Clears transaction listenersprotected voiddoReadWrite()Threaded transactions should be open immediately upon creation so most implementations should do nothing with this method.protected voidfireOnCommit()Called withinAbstractTransaction.commit()just after the internal call toAbstractTransaction.doCommit().protected voidfireOnRollback()Called withinAbstractTransaction.rollback()just after the internal call toAbstractTransaction.doRollback()()}.TransactiononClose(Consumer<Transaction> consumer)The nature of threaded transactions are such that they are always open when created and manual in nature, therefore setting this value is not required.TransactiononReadWrite(Consumer<Transaction> consumer)The nature of threaded transactions are such that they are always open when created and manual in nature, therefore setting this value is not required.voidremoveTransactionListener(Consumer<Transaction.Status> listener)Removes a transaction listener.- 
Methods inherited from class org.apache.tinkerpop.gremlin.structure.util.AbstractTransactionbegin, close, commit, createThreadedTx, doCommit, doOpen, doRollback, open, readWrite, rollback
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tinkerpop.gremlin.structure.Transactionbegin, isOpen
 
- 
 
- 
- 
- 
Field Detail- 
transactionListenersprotected final List<Consumer<Transaction.Status>> transactionListeners 
 
- 
 - 
Constructor Detail- 
AbstractThreadedTransactionpublic AbstractThreadedTransaction(Graph g) 
 
- 
 - 
Method Detail- 
fireOnCommitprotected void fireOnCommit() Description copied from class:AbstractTransactionCalled withinAbstractTransaction.commit()just after the internal call toAbstractTransaction.doCommit(). Implementations of this method should raiseTransaction.Status.COMMITevents to any listeners added viaTransaction.addTransactionListener(Consumer).- Specified by:
- fireOnCommitin class- AbstractTransaction
 
 - 
fireOnRollbackprotected void fireOnRollback() Description copied from class:AbstractTransactionCalled withinAbstractTransaction.rollback()just after the internal call toAbstractTransaction.doRollback()()}. Implementations of this method should raiseTransaction.Status.ROLLBACKevents to any listeners added viaTransaction.addTransactionListener(Consumer).- Specified by:
- fireOnRollbackin class- AbstractTransaction
 
 - 
addTransactionListenerpublic void addTransactionListener(Consumer<Transaction.Status> listener) Description copied from interface:TransactionAdds 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.
 - 
removeTransactionListenerpublic void removeTransactionListener(Consumer<Transaction.Status> listener) Description copied from interface:TransactionRemoves a transaction listener.
 - 
clearTransactionListenerspublic void clearTransactionListeners() Description copied from interface:TransactionRemoves all transaction listeners.
 - 
doReadWriteprotected void doReadWrite() Threaded transactions should be open immediately upon creation so most implementations should do nothing with this method.- Specified by:
- doReadWritein class- AbstractTransaction
 
 - 
doCloseprotected void doClose() Clears transaction listeners- Specified by:
- doClosein class- AbstractTransaction
 
 - 
onReadWritepublic Transaction onReadWrite(Consumer<Transaction> consumer) The nature of threaded transactions are such that they are always open when created and manual in nature, therefore setting this value is not required.- Throws:
- UnsupportedOperationException
 
 - 
onClosepublic Transaction onClose(Consumer<Transaction> consumer) The nature of threaded transactions are such that they are always open when created and manual in nature, therefore setting this value is not required.- Throws:
- UnsupportedOperationException
 
 
- 
 
-