public abstract class AbstractThreadLocalTransaction extends AbstractTransaction
Transaction that provides core functionality for transaction listeners using
ThreadLocal. In this implementation, the listeners are bound to the current thread of execution (usually
the same as the transaction for most graph database implementations). Therefore, when AbstractTransaction.commit() is
called on a particular thread, the only listeners that get notified are those bound to that thread.AbstractThreadedTransactionAbstractTransaction.TransactionExceptionTransaction.CLOSE_BEHAVIOR, Transaction.Exceptions, Transaction.READ_WRITE_BEHAVIOR, Transaction.Status, Transaction.Workload<R>| Modifier and Type | Field and Description |
|---|---|
protected ThreadLocal<Consumer<Transaction>> |
closeConsumerInternal |
protected ThreadLocal<Consumer<Transaction>> |
readWriteConsumerInternal |
protected ThreadLocal<List<Consumer<Transaction.Status>>> |
transactionListeners |
| Constructor and Description |
|---|
AbstractThreadLocalTransaction(Graph g) |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransactionListener(Consumer<Transaction.Status> listener)
Adds a listener that is called back with a status when a commit or rollback is successful.
|
void |
clearTransactionListeners()
Removes all transaction listeners.
|
protected void |
doClose()
Called
AbstractTransaction.close(). |
protected void |
doReadWrite()
Called
AbstractTransaction.readWrite(). |
protected void |
fireOnCommit()
Called within
AbstractTransaction.commit() just after the internal call to AbstractTransaction.doCommit(). |
protected void |
fireOnRollback()
Called within
AbstractTransaction.rollback() just after the internal call to AbstractTransaction.doRollback() ()}. |
Transaction |
onClose(Consumer<Transaction> consumer)
Describes what happens to a transaction on a call to
Graph.close(). |
Transaction |
onReadWrite(Consumer<Transaction> consumer)
Describes how a transaction is started when a read or a write occurs.
|
void |
removeTransactionListener(Consumer<Transaction.Status> listener)
Removes a transaction listener.
|
close, commit, createThreadedTx, doCommit, doOpen, doRollback, open, readWrite, rollback, submitclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisOpenprotected final ThreadLocal<Consumer<Transaction>> readWriteConsumerInternal
protected final ThreadLocal<Consumer<Transaction>> closeConsumerInternal
protected final ThreadLocal<List<Consumer<Transaction.Status>>> transactionListeners
public AbstractThreadLocalTransaction(Graph g)
protected void fireOnCommit()
AbstractTransactionAbstractTransaction.commit() just after the internal call to AbstractTransaction.doCommit(). Implementations of this
method should raise Status#COMMIT events to any listeners added via
Transaction.addTransactionListener(Consumer).fireOnCommit in class AbstractTransactionprotected void fireOnRollback()
AbstractTransactionAbstractTransaction.rollback() just after the internal call to AbstractTransaction.doRollback() ()}. Implementations
of this method should raise Status#ROLLBACK events to any listeners added via
Transaction.addTransactionListener(Consumer).fireOnRollback in class AbstractTransactionpublic void addTransactionListener(Consumer<Transaction.Status> listener)
Transactionpublic void removeTransactionListener(Consumer<Transaction.Status> listener)
Transactionpublic void clearTransactionListeners()
Transactionprotected void doReadWrite()
AbstractTransactionAbstractTransaction.readWrite().
Implementers should run their readWrite consumer here.doReadWrite in class AbstractTransactionprotected void doClose()
AbstractTransactionAbstractTransaction.close().
Implementers should run their readWrite consumer here.doClose in class AbstractTransactionpublic Transaction onReadWrite(Consumer<Transaction> consumer)
TransactionTransaction.READ_WRITE_BEHAVIOR or a mapper Consumer function.public Transaction onClose(Consumer<Transaction> consumer)
TransactionGraph.close(). This value can be set using
standard behavior defined in Transaction.CLOSE_BEHAVIOR or a mapper Consumer function.Copyright © 2013–2015 Apache Software Foundation. All rights reserved.