Class DefaultCompensatingTransactionOperationManager
java.lang.Object
org.springframework.transaction.compensating.support.DefaultCompensatingTransactionOperationManager
- All Implemented Interfaces:
CompensatingTransactionOperationManager
public class DefaultCompensatingTransactionOperationManager
extends Object
implements CompensatingTransactionOperationManager
Default implementation of
CompensatingTransactionOperationManager.
Manages a stack of CompensatingTransactionOperationExecutor objects
and performs rollback of these in the reverse order.- Since:
- 1.2
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCompensatingTransactionOperationManager(CompensatingTransactionOperationFactory operationFactory) Set theCompensatingTransactionOperationFactoryto use. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commit all recorded operations.protected Stack<CompensatingTransactionOperationExecutor>Get the rollback operations.voidperformOperation(Object resource, String operation, Object[] args) Indicates that the supplied operation (method name) is to be performed.voidrollback()Rollback all recorded operations by performing each of the recorded rollback operations.
-
Constructor Details
-
DefaultCompensatingTransactionOperationManager
public DefaultCompensatingTransactionOperationManager(CompensatingTransactionOperationFactory operationFactory) Set theCompensatingTransactionOperationFactoryto use.- Parameters:
operationFactory- theCompensatingTransactionOperationFactory.
-
-
Method Details
-
performOperation
Description copied from interface:CompensatingTransactionOperationManagerIndicates that the supplied operation (method name) is to be performed. This method is responsible for recording the current state (prior to the operation), performing the operation, and storing the necessary information to roll back or commit the performed operation.- Specified by:
performOperationin interfaceCompensatingTransactionOperationManager- Parameters:
resource- the target resource to perform the operation on.operation- The method to be invoked.args- Arguments supplied to the method.
-
rollback
public void rollback()Description copied from interface:CompensatingTransactionOperationManagerRollback all recorded operations by performing each of the recorded rollback operations.- Specified by:
rollbackin interfaceCompensatingTransactionOperationManager
-
getOperationExecutors
Get the rollback operations. Used for testing purposes.- Returns:
- the rollback operations.
-
commit
public void commit()Description copied from interface:CompensatingTransactionOperationManagerCommit all recorded operations. In many cases this means doing nothing, but in some cases some temporary data will need to be removed.- Specified by:
commitin interfaceCompensatingTransactionOperationManager
-