public abstract class BasicTransactionSemantics extends Object implements Transaction
 An implementation of basic Transaction semantics designed
 to work in concert with BasicChannelSemantics to simplify
 creation of robust Channel implementations.  This class
 ensures that each transaction implementation method is called only
 while the transaction is in the correct state for that method, and
 only by the thread that created the transaction.  Nested calls to
 begin() and close() are supported as long
 as they are balanced.
 
 Subclasses need only implement doPut,
 doTake, doCommit, and
 doRollback, and the developer can rest assured that
 those methods are called only after transaction state preconditions
 have been properly met.  doBegin and
 doClose may also be implemented if there is work to be
 done at those points.
 
 All InterruptedException exceptions thrown from the implementations
 of the doXXX methods are automatically wrapped to
 become ChannelExceptions, but only after restoring the interrupted
 status of the thread so that any subsequent blocking method calls
 will themselves throw InterruptedException rather than blocking.
 The exception to this rule is doTake, which simply
 returns null instead of wrapping and propagating the
 InterruptedException, though it still first restores the
 interrupted status of the thread.
 
| Modifier and Type | Class and Description | 
|---|---|
| protected static class  | BasicTransactionSemantics.State
 The state of the  Transactionto which it belongs. | 
Transaction.TransactionState| Modifier | Constructor and Description | 
|---|---|
| protected  | BasicTransactionSemantics() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | begin()Starts a transaction boundary for the current channel operation. | 
| void | close()Ends a transaction boundary for the current channel operation. | 
| void | commit()Indicates that the transaction can be successfully committed. | 
| protected void | doBegin() | 
| protected void | doClose() | 
| protected abstract void | doCommit() | 
| protected abstract void | doPut(Event event) | 
| protected abstract void | doRollback() | 
| protected abstract Event | doTake() | 
| protected BasicTransactionSemantics.State | getState() | 
| protected void | put(Event event)
 The method to which  BasicChannelSemanticsdelegates calls
 toput. | 
| void | rollback()Indicates that the transaction can must be aborted. | 
| protected Event | take()
 The method to which  BasicChannelSemanticsdelegates calls
 totake. | 
| String | toString() | 
protected void doBegin()
                throws InterruptedException
InterruptedExceptionprotected abstract void doPut(Event event) throws InterruptedException
InterruptedExceptionprotected abstract Event doTake() throws InterruptedException
InterruptedExceptionprotected abstract void doCommit()
                          throws InterruptedException
InterruptedExceptionprotected abstract void doRollback()
                            throws InterruptedException
InterruptedExceptionprotected void doClose()
protected void put(Event event)
 The method to which BasicChannelSemantics delegates calls
 to put.
 
protected Event take()
 The method to which BasicChannelSemantics delegates calls
 to take.
 
protected BasicTransactionSemantics.State getState()
public void begin()
TransactionStarts a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting.
Note: For every invocation of this method there must be a corresponding invocation of Transaction.close() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
begin in interface Transactionpublic void commit()
Transactioncommit in interface Transactionpublic void rollback()
Transactionrollback in interface Transactionpublic void close()
TransactionEnds a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting. The transaction is completed only if there are no more references left for this transaction.
Note: For every invocation of this method there must be a corresponding invocation of Transaction.begin() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
close in interface TransactionCopyright © 2009-2017 Apache Software Foundation. All Rights Reserved.