Package io.micronaut.transaction.impl
Class AbstractInternalTransaction<C>
java.lang.Object
io.micronaut.transaction.impl.AbstractInternalTransaction<C>
- Type Parameters:
C
- The connection type
- All Implemented Interfaces:
InternalTransaction<C>
,TransactionExecution
,TransactionStatus<C>
- Direct Known Subclasses:
DefaultTransactionStatus
@Internal
public abstract class AbstractInternalTransaction<C>
extends Object
implements InternalTransaction<C>
The abstract internal transaction.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
Return whether this transaction is completed, that is, whether it has already been committed or rolled back.boolean
Template method for determining the global rollback-only flag of the underlying transaction, if any.boolean
Determine the rollback-only flag via checking this TransactionStatus.boolean
Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).void
registerInvocationSynchronization
(@NonNull TransactionSynchronization synchronization) The variation ofTransactionStatus.registerSynchronization(TransactionSynchronization)
that is always executed on the current TX invocation.void
registerSynchronization
(@NonNull TransactionSynchronization synchronization) Register a new transaction synchronization for the current state.protected void
Set global rollback only.void
Set the transaction rollback-only.void
void
void
void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.transaction.impl.InternalTransaction
isNestedTransaction, resume, suspend
Methods inherited from interface io.micronaut.transaction.TransactionExecution
getTransactionDefinition, isNewTransaction
Methods inherited from interface io.micronaut.transaction.TransactionStatus
getConnection, getConnectionStatus, getTransaction
-
Field Details
-
synchronizations
-
-
Constructor Details
-
AbstractInternalTransaction
public AbstractInternalTransaction()
-
-
Method Details
-
setGlobalRollbackOnly
protected void setGlobalRollbackOnly()Set global rollback only. -
setRollbackOnly
public void setRollbackOnly()Description copied from interface:TransactionExecution
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.- Specified by:
setRollbackOnly
in interfaceTransactionExecution
-
isRollbackOnly
public boolean isRollbackOnly()Description copied from interface:TransactionExecution
Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).- Specified by:
isRollbackOnly
in interfaceTransactionExecution
- Returns:
- Whether the execution has been marked to rollback
-
isLocalRollbackOnly
public boolean isLocalRollbackOnly()Description copied from interface:InternalTransaction
Determine the rollback-only flag via checking this TransactionStatus.Will only return "true" if the application called
setRollbackOnly
on this TransactionStatus object.- Specified by:
isLocalRollbackOnly
in interfaceInternalTransaction<C>
- Returns:
- Whether is local rollback
-
isGlobalRollbackOnly
public boolean isGlobalRollbackOnly()Description copied from interface:InternalTransaction
Template method for determining the global rollback-only flag of the underlying transaction, if any.This implementation always returns
false
.- Specified by:
isGlobalRollbackOnly
in interfaceInternalTransaction<C>
- Returns:
- Whether is global rollback
-
isCompleted
public boolean isCompleted()Description copied from interface:TransactionExecution
Return whether this transaction is completed, that is, whether it has already been committed or rolled back.- Specified by:
isCompleted
in interfaceTransactionExecution
- Returns:
- Whether the execution has completed
-
triggerBeforeCommit
public void triggerBeforeCommit()- Specified by:
triggerBeforeCommit
in interfaceInternalTransaction<C>
-
triggerAfterCommit
public void triggerAfterCommit()- Specified by:
triggerAfterCommit
in interfaceInternalTransaction<C>
-
triggerBeforeCompletion
public void triggerBeforeCompletion()- Specified by:
triggerBeforeCompletion
in interfaceInternalTransaction<C>
-
triggerAfterCompletion
- Specified by:
triggerAfterCompletion
in interfaceInternalTransaction<C>
-
cleanupAfterCompletion
public void cleanupAfterCompletion()- Specified by:
cleanupAfterCompletion
in interfaceInternalTransaction<C>
-
registerSynchronization
Description copied from interface:TransactionStatus
Register a new transaction synchronization for the current state.Note that synchronizations can implement the
Ordered
interface. They will be executed in an order according to their order value (if any).- Specified by:
registerSynchronization
in interfaceTransactionStatus<C>
- Parameters:
synchronization
- the synchronization object to register
-
registerInvocationSynchronization
public void registerInvocationSynchronization(@NonNull @NonNull TransactionSynchronization synchronization) Description copied from interface:InternalTransaction
The variation ofTransactionStatus.registerSynchronization(TransactionSynchronization)
that is always executed on the current TX invocation. The ordinaryTransactionStatus.registerSynchronization(TransactionSynchronization)
will always bound the synchronization to the TX in progress.- Specified by:
registerInvocationSynchronization
in interfaceInternalTransaction<C>
- Parameters:
synchronization
- The synchronization
-