Package com.yahoo.transaction
Class AbstractTransaction
- java.lang.Object
-
- com.yahoo.transaction.AbstractTransaction
-
- All Implemented Interfaces:
Transaction
,java.lang.AutoCloseable
public abstract class AbstractTransaction extends java.lang.Object implements Transaction
A convenience base transaction class for multi-operation transactions which maintains the ordered list of operations to commit and provides a default implementation of rollbackOrLog which logs a SEVERE message.- Author:
- bratseth
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.yahoo.transaction.Transaction
Transaction.Operation
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTransaction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Transaction
add(Transaction.Operation operation)
Adds an operation to this transaction.Transaction
add(java.util.List<Transaction.Operation> operations)
Adds multiple operations to this transaction.void
close()
Default implementation which only clears operationsjava.util.List<Transaction.Operation>
operations()
Returns the operations of this.void
rollbackOrLog()
Default implementations which logs a severe message.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.yahoo.transaction.Transaction
commit, prepare
-
-
-
-
Method Detail
-
add
public Transaction add(Transaction.Operation operation)
Description copied from interface:Transaction
Adds an operation to this transaction. Return self for chaining.- Specified by:
add
in interfaceTransaction
- Parameters:
operation
-Transaction.Operation
to append- Returns:
- self, for chaining
-
add
public Transaction add(java.util.List<Transaction.Operation> operations)
Description copied from interface:Transaction
Adds multiple operations to this transaction. Return self for chaining.- Specified by:
add
in interfaceTransaction
- Parameters:
operations
-Transaction.Operation
to append- Returns:
- self, for chaining
-
operations
public java.util.List<Transaction.Operation> operations()
Description copied from interface:Transaction
Returns the operations of this. Ownership of the returned list is transferred to the caller. The ist may be ready only.- Specified by:
operations
in interfaceTransaction
-
rollbackOrLog
public void rollbackOrLog()
Default implementations which logs a severe message. Operations should implement toString to use this.- Specified by:
rollbackOrLog
in interfaceTransaction
-
close
public void close()
Default implementation which only clears operations- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceTransaction
-
-