T
- The transaction object typepublic class DefaultTransactionStatus<T> extends AbstractTransactionStatus<T>
TransactionStatus
interface, used by AbstractSynchronousTransactionManager
. Based on the concept
of an underlying "transaction object".
Holds all status information that AbstractSynchronousTransactionManager
needs internally, including a generic transaction object determined by the
concrete transaction manager implementation.
Supports delegating savepoint-related methods to a transaction object
that implements the SavepointManager
interface.
NOTE: This is not intended for use with other PlatformTransactionManager
implementations, in particular not for mock transaction managers in testing environments.
TransactionStatus
interface instead.
AbstractSynchronousTransactionManager
,
SavepointManager
,
getTransaction()
,
AbstractTransactionStatus.createSavepoint()
,
AbstractTransactionStatus.rollbackToSavepoint(java.lang.Object)
,
AbstractTransactionStatus.releaseSavepoint(java.lang.Object)
Constructor and Description |
---|
DefaultTransactionStatus(java.lang.Object transaction,
java.util.function.Supplier<T> connectionSupplier,
boolean newTransaction,
boolean newSynchronization,
boolean readOnly,
boolean debug,
java.lang.Object suspendedResources)
Create a new
DefaultTransactionStatus instance. |
Modifier and Type | Method and Description |
---|---|
void |
flush()
Delegate the flushing to the transaction object, provided that the latter
implements the
SmartTransactionObject interface. |
T |
getConnection() |
protected SavepointManager |
getSavepointManager()
This implementation exposes the
SavepointManager interface
of the underlying transaction object, if any. |
java.lang.Object |
getSuspendedResources()
Return the holder for resources that have been suspended for this transaction,
if any.
|
java.lang.Object |
getTransaction()
Return the underlying transaction object.
|
boolean |
hasTransaction()
Return whether there is an actual transaction active.
|
boolean |
isDebug()
Return whether the progress of this transaction is debugged.
|
boolean |
isGlobalRollbackOnly()
Determine the rollback-only flag via checking the transaction object, provided
that the latter implements the
SmartTransactionObject interface. |
boolean |
isNewSynchronization()
Return if a new transaction synchronization has been opened
for this transaction.
|
boolean |
isNewTransaction()
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.
|
boolean |
isReadOnly()
Return if this transaction is defined as read-only transaction.
|
boolean |
isTransactionSavepointManager()
Return whether the underlying transaction implements the
SavepointManager
interface and therefore supports savepoints. |
createAndHoldSavepoint, createSavepoint, getSavepoint, hasSavepoint, isCompleted, isLocalRollbackOnly, isRollbackOnly, releaseHeldSavepoint, releaseSavepoint, rollbackToHeldSavepoint, rollbackToSavepoint, setCompleted, setRollbackOnly, setSavepoint
public DefaultTransactionStatus(@Nullable java.lang.Object transaction, @NonNull java.util.function.Supplier<T> connectionSupplier, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, @Nullable java.lang.Object suspendedResources)
DefaultTransactionStatus
instance.transaction
- underlying transaction object that can hold state
for the internal transaction implementationconnectionSupplier
- The connection suppliernewTransaction
- 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@NonNull public T getConnection()
public java.lang.Object getTransaction()
java.lang.IllegalStateException
- if no transaction is activepublic boolean hasTransaction()
public boolean isNewTransaction()
TransactionExecution
public boolean isNewSynchronization()
public boolean isReadOnly()
public boolean isDebug()
AbstractSynchronousTransactionManager
as an optimization, to prevent repeated
calls to logger.isDebugEnabled()
. Not really intended for client code.@Nullable public java.lang.Object getSuspendedResources()
public boolean isGlobalRollbackOnly()
SmartTransactionObject
interface.
Will return true
if the global transaction itself has been marked
rollback-only by the transaction coordinator, for example in case of a timeout.
isGlobalRollbackOnly
in class AbstractTransactionStatus<T>
SmartTransactionObject.isRollbackOnly()
protected SavepointManager getSavepointManager()
SavepointManager
interface
of the underlying transaction object, if any.getSavepointManager
in class AbstractTransactionStatus<T>
NestedTransactionNotSupportedException
- if savepoints are not supportedisTransactionSavepointManager()
public boolean isTransactionSavepointManager()
SavepointManager
interface and therefore supports savepoints.getTransaction()
,
getSavepointManager()
public void flush()
SmartTransactionObject
interface.flush
in interface TransactionStatus<T>
flush
in interface java.io.Flushable
flush
in class AbstractTransactionStatus<T>
SmartTransactionObject.flush()