Top Description Fields Constructors Methods
org.springframework.transaction.reactive

public Class GenericReactiveTransaction

extends Object
implements ReactiveTransaction
Class Inheritance
All Implemented Interfaces
org.springframework.transaction.ReactiveTransaction, org.springframework.transaction.TransactionExecution
Imports
org.springframework.lang.Nullable, org.springframework.transaction.ReactiveTransaction, org.springframework.util.Assert

Default implementation of the ReactiveTransaction interface, used by AbstractReactiveTransactionManager. Based on the concept of an underlying "transaction object".

Holds all status information that AbstractReactiveTransactionManager needs 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.

Authors
Mark Paluch, Juergen Hoeller
Since
5.2
See Also
AbstractReactiveTransactionManager, getTransaction

Field Summary

Modifier and TypeField and Description
private boolean
private final boolean
private final boolean
private final boolean
private final boolean
private final boolean
private boolean
private final Object
private final Object
private final String

Constructor Summary

AccessConstructor and Description
public
GenericReactiveTransaction(String
the defined name of the transaction
transactionName
,
Object
underlying transaction object that can hold state for the internal transaction implementation
transaction
,
boolean
if the transaction is new, otherwise participating in an existing transaction
newTransaction
,
boolean
if a new transaction synchronization has been opened for the given transaction
newSynchronization
,
boolean nested, boolean
whether the transaction is marked as read-only
readOnly
,
boolean
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.
debug
,
Object
a holder for resources that have been suspended for this transaction, if any
suspendedResources
)

Create a new DefaultReactiveTransactionStatus instance.

public
GenericReactiveTransaction(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources)
Deprecated for removal since 6.1.

Method Summary

Modifier and TypeMethod and Description
public Object
getSuspendedResources()

Return the holder for resources that have been suspended for this transaction, if any.

public Object
getTransaction()

Return the underlying transaction object.

public String
getTransactionName()

Overrides default org.springframework.transaction.TransactionExecution.getTransactionName.

Return the defined name of the transaction (possibly an empty String).

public boolean
hasTransaction()

Overrides default org.springframework.transaction.TransactionExecution.hasTransaction.

Return whether there is an actual transaction active: this is meant to cover a new transaction as well as participation in an existing transaction, only returning false when not running in an actual transaction at all.

public boolean
isCompleted()

Overrides default org.springframework.transaction.TransactionExecution.isCompleted.

Return whether this transaction is completed, that is, whether it has already been committed or rolled back.

public boolean
isDebug()

Return whether the progress of this transaction is debugged.

public boolean
isNested()

Overrides default org.springframework.transaction.TransactionExecution.isNested.

Return if this transaction executes in a nested fashion within another.

public boolean
isNewSynchronization()

Return if a new transaction synchronization has been opened for this transaction.

public boolean
isNewTransaction()

Overrides default org.springframework.transaction.TransactionExecution.isNewTransaction.

Return whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.

public boolean
isReadOnly()

Overrides default org.springframework.transaction.TransactionExecution.isReadOnly.

Return if this transaction is defined as read-only transaction.

public boolean
isRollbackOnly()

Overrides default org.springframework.transaction.TransactionExecution.isRollbackOnly.

Determine the rollback-only flag via checking this ReactiveTransactionStatus.

public void
setCompleted()

Mark this transaction as completed, that is, committed or rolled back.

public void
setRollbackOnly()

Overrides default org.springframework.transaction.TransactionExecution.setRollbackOnly.

Set the transaction rollback-only.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

completedback to summary
private boolean completed
debugback to summary
private final boolean debug
nestedback to summary
private final boolean nested
newSynchronizationback to summary
private final boolean newSynchronization
newTransactionback to summary
private final boolean newTransaction
readOnlyback to summary
private final boolean readOnly
rollbackOnlyback to summary
private boolean rollbackOnly
suspendedResourcesback to summary
private final Object suspendedResources
Annotations
@Nullable
transactionback to summary
private final Object transaction
Annotations
@Nullable
transactionNameback to summary
private final String transactionName
Annotations
@Nullable

Constructor Detail

GenericReactiveTransactionback to summary
public GenericReactiveTransaction(String transactionName, Object transaction, boolean newTransaction, boolean newSynchronization, boolean nested, boolean readOnly, boolean debug, Object suspendedResources)

Create a new DefaultReactiveTransactionStatus instance.

Parameters
transactionName:String

the defined name of the transaction

transaction:Object

underlying transaction object that can hold state for the internal transaction implementation

newTransaction:boolean

if the transaction is new, otherwise participating in an existing transaction

newSynchronization:boolean

if a new transaction synchronization has been opened for the given transaction

readOnly:boolean

whether the transaction is marked as read-only

debug:boolean

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:Object

a holder for resources that have been suspended for this transaction, if any

Since
6.1
GenericReactiveTransactionback to summary
public GenericReactiveTransaction(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources)

Deprecated

for removal since 6.1.

Annotations
@Deprecated
since:6.1
forRemoval:true

Method Detail

getSuspendedResourcesback to summary
public Object getSuspendedResources()

Return the holder for resources that have been suspended for this transaction, if any.

Annotations
@Nullable
getTransactionback to summary
public Object getTransaction()

Return the underlying transaction object.

Exceptions
IllegalStateException:
if no transaction is active
getTransactionNameback to summary
public String getTransactionName()

Overrides default org.springframework.transaction.TransactionExecution.getTransactionName.

Doc from org.springframework.transaction.TransactionExecution.getTransactionName.

Return the defined name of the transaction (possibly an empty String).

In case of Spring's declarative transactions, the exposed name will be the fully-qualified class name + "." + method name (by default).

The default implementation returns an empty String.

Annotations
@Override
hasTransactionback to summary
public boolean hasTransaction()

Overrides default org.springframework.transaction.TransactionExecution.hasTransaction.

Doc from org.springframework.transaction.TransactionExecution.hasTransaction.

Return whether there is an actual transaction active: this is meant to cover a new transaction as well as participation in an existing transaction, only returning false when not running in an actual transaction at all.

The default implementation returns true.

Annotations
@Override
isCompletedback to summary
public boolean isCompleted()

Overrides default org.springframework.transaction.TransactionExecution.isCompleted.

Doc from org.springframework.transaction.TransactionExecution.isCompleted.

Return whether this transaction is completed, that is, whether it has already been committed or rolled back.

The default implementation returns false.

Annotations
@Override
isDebugback to summary
public boolean isDebug()

Return whether the progress of this transaction is debugged. This is used by AbstractReactiveTransactionManager as an optimization, to prevent repeated calls to logger.isDebugEnabled(). Not really intended for client code.

isNestedback to summary
public boolean isNested()

Overrides default org.springframework.transaction.TransactionExecution.isNested.

Doc from org.springframework.transaction.TransactionExecution.isNested.

Return if this transaction executes in a nested fashion within another.

The default implementation returns false.

Annotations
@Override
isNewSynchronizationback to summary
public boolean isNewSynchronization()

Return if a new transaction synchronization has been opened for this transaction.

isNewTransactionback to summary
public boolean isNewTransaction()

Overrides default org.springframework.transaction.TransactionExecution.isNewTransaction.

Doc from org.springframework.transaction.TransactionExecution.isNewTransaction.

Return whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.

This is primarily here for transaction manager state handling. Prefer the use of hasTransaction() for application purposes since this is usually semantically appropriate.

The "new" status can be transaction manager specific, e.g. returning true for an actual nested transaction but potentially false for a savepoint-based nested transaction scope if the savepoint management is explicitly exposed (such as on TransactionStatus). A combined check for any kind of nested execution is provided by isNested().

The default implementation returns true.

Annotations
@Override
isReadOnlyback to summary
public boolean isReadOnly()

Overrides default org.springframework.transaction.TransactionExecution.isReadOnly.

Doc from org.springframework.transaction.TransactionExecution.isReadOnly.

Return if this transaction is defined as read-only transaction.

The default implementation returns false.

Annotations
@Override
isRollbackOnlyback to summary
public boolean isRollbackOnly()

Overrides default org.springframework.transaction.TransactionExecution.isRollbackOnly.

Determine the rollback-only flag via checking this ReactiveTransactionStatus.

Will only return "true" if the application called setRollbackOnly on this TransactionStatus object.

Annotations
@Override
setCompletedback to summary
public void setCompleted()

Mark this transaction as completed, that is, committed or rolled back.

setRollbackOnlyback to summary
public void setRollbackOnly()

Overrides default org.springframework.transaction.TransactionExecution.setRollbackOnly.

Doc from org.springframework.transaction.TransactionExecution.setRollbackOnly.

Set 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.

The default implementation throws an UnsupportedOperationException.

Annotations
@Override