类 GenericReactiveTransaction
- java.lang.Object
- org.springframework.transaction.reactive.GenericReactiveTransaction
- 所有已实现的接口:
ReactiveTransaction,TransactionExecution
public class GenericReactiveTransaction extends Object implements ReactiveTransaction
Default implementation of theReactiveTransactioninterface, used byAbstractReactiveTransactionManager. Based on the concept of an underlying "transaction object".Holds all status information that
AbstractReactiveTransactionManagerneeds internally, including a generic transaction object determined by the concrete transaction manager implementation.NOTE: This is not intended for use with other ReactiveTransactionManager implementations, in particular not for mock transaction managers in testing environments.
- 从以下版本开始:
- 5.2
- 作者:
- Mark Paluch, Juergen Hoeller
- 另请参阅:
AbstractReactiveTransactionManager,getTransaction()
构造器概要
构造器 构造器 说明 GenericReactiveTransaction(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources)Create a newDefaultReactiveTransactionStatusinstance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ObjectgetSuspendedResources()Return the holder for resources that have been suspended for this transaction, if any.ObjectgetTransaction()Return the underlying transaction object.booleanhasTransaction()Return whether there is an actual transaction active.booleanisCompleted()Return whether this transaction is completed, that is, whether it has already been committed or rolled back.booleanisDebug()Return whether the progress of this transaction is debugged.booleanisNewSynchronization()Return if a new transaction synchronization has been opened for this transaction.booleanisNewTransaction()Return whether the present transaction is new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.booleanisReadOnly()Return if this transaction is defined as read-only transaction.booleanisRollbackOnly()Determine the rollback-only flag via checking this ReactiveTransactionStatus.voidsetCompleted()Mark this transaction as completed, that is, committed or rolled back.voidsetRollbackOnly()Set the transaction rollback-only.
构造器详细资料
GenericReactiveTransaction
public GenericReactiveTransaction(@Nullable Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, @Nullable Object suspendedResources)
Create a newDefaultReactiveTransactionStatusinstance.- 参数:
transaction- underlying transaction object that can hold state for the internal transaction implementationnewTransaction- if the transaction is new, otherwise participating in an existing transactionnewSynchronization- if a new transaction synchronization has been opened for the given transactionreadOnly- whether the transaction is marked as read-onlydebug- should debug logging be enabled for the handling of this transaction? Caching it in here can prevent repeated calls to ask the logging system whether debug logging should be enabled.suspendedResources- a holder for resources that have been suspended for this transaction, if any
方法详细资料
getTransaction
public Object getTransaction()
Return the underlying transaction object.- 抛出:
IllegalStateException- if no transaction is active
hasTransaction
public boolean hasTransaction()
Return whether there is an actual transaction active.
isNewTransaction
public boolean isNewTransaction()
从接口复制的说明:TransactionExecutionReturn whether the present transaction is new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.- 指定者:
isNewTransaction在接口中TransactionExecution
isNewSynchronization
public boolean isNewSynchronization()
Return if a new transaction synchronization has been opened for this transaction.
isReadOnly
public boolean isReadOnly()
Return if this transaction is defined as read-only transaction.
isDebug
public boolean isDebug()
Return whether the progress of this transaction is debugged. This is used byAbstractReactiveTransactionManageras an optimization, to prevent repeated calls tologger.isDebugEnabled(). Not really intended for client code.
getSuspendedResources
@Nullable public Object getSuspendedResources()
Return the holder for resources that have been suspended for this transaction, if any.
setRollbackOnly
public void setRollbackOnly()
从接口复制的说明:TransactionExecutionSet the transaction rollback-only. This instructs the transaction manager that the only possible outcome of the transaction may be a rollback, as alternative to throwing an exception which would in turn trigger a rollback.- 指定者:
setRollbackOnly在接口中TransactionExecution
isRollbackOnly
public boolean isRollbackOnly()
Determine the rollback-only flag via checking this ReactiveTransactionStatus.Will only return "true" if the application called
setRollbackOnlyon this TransactionStatus object.- 指定者:
isRollbackOnly在接口中TransactionExecution
setCompleted
public void setCompleted()
Mark this transaction as completed, that is, committed or rolled back.
isCompleted
public boolean isCompleted()
从接口复制的说明:TransactionExecutionReturn whether this transaction is completed, that is, whether it has already been committed or rolled back.- 指定者:
isCompleted在接口中TransactionExecution