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.AbstractThreadedTransaction
AbstractTransaction.TransactionException
Transaction.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, submit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isOpen
protected 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()
AbstractTransaction
AbstractTransaction.commit()
just after the internal call to AbstractTransaction.doCommit()
. Implementations of this
method should raise Transaction.Status.COMMIT
events to any
listeners added via Transaction.addTransactionListener(Consumer)
.fireOnCommit
in class AbstractTransaction
protected void fireOnRollback()
AbstractTransaction
AbstractTransaction.rollback()
just after the internal call to AbstractTransaction.doRollback()
()}. Implementations
of this method should raise Transaction.Status.ROLLBACK
events
to any listeners added via Transaction.addTransactionListener(Consumer)
.fireOnRollback
in class AbstractTransaction
public void addTransactionListener(Consumer<Transaction.Status> listener)
Transaction
public void removeTransactionListener(Consumer<Transaction.Status> listener)
Transaction
public void clearTransactionListeners()
Transaction
protected void doReadWrite()
AbstractTransaction
AbstractTransaction.readWrite()
.
Implementers should run their readWrite consumer here.doReadWrite
in class AbstractTransaction
protected void doClose()
AbstractTransaction
AbstractTransaction.close()
.
Implementers should run their readWrite consumer here.doClose
in class AbstractTransaction
public Transaction onReadWrite(Consumer<Transaction> consumer)
Transaction
Transaction.READ_WRITE_BEHAVIOR
or a mapper Consumer
function.public Transaction onClose(Consumer<Transaction> consumer)
Transaction
Graph.close()
. This value can be set using
standard behavior defined in Transaction.CLOSE_BEHAVIOR
or a mapper Consumer
function.Copyright © 2013–2017 Apache Software Foundation. All rights reserved.