public abstract class AbstractThreadedTransaction extends AbstractTransaction
Transaction
that provides core functionality for transaction listeners using a
shared set of transaction listeners. Therefore, when AbstractTransaction.commit()
is called from any thread, all listeners
get notified. This implementation would be useful for graph implementations that support threaded transactions,
specifically in the Graph
instance returned from Transaction.createThreadedTx()
.AbstractThreadLocalTransaction
AbstractTransaction.TransactionException
Transaction.CLOSE_BEHAVIOR, Transaction.Exceptions, Transaction.READ_WRITE_BEHAVIOR, Transaction.Status, Transaction.Workload<R>
Modifier and Type | Field and Description |
---|---|
protected List<Consumer<Transaction.Status>> |
transactionListeners |
Constructor and Description |
---|
AbstractThreadedTransaction(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()
Clears transaction listeners
|
protected void |
doReadWrite()
Threaded transactions should be open immediately upon creation so most implementations should do nothing with
this method.
|
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)
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.
|
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.
|
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 List<Consumer<Transaction.Status>> transactionListeners
public AbstractThreadedTransaction(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()
doReadWrite
in class AbstractTransaction
protected void doClose()
doClose
in class AbstractTransaction
public Transaction onReadWrite(Consumer<Transaction> consumer)
UnsupportedOperationException
public Transaction onClose(Consumer<Transaction> consumer)
UnsupportedOperationException
Copyright © 2013–2016 Apache Software Foundation. All rights reserved.