- All Implemented Interfaces:
Serializable,ConnectionProvider,TransactionControl,TransactionManager,org.springframework.beans.factory.InitializingBean,org.springframework.transaction.ConfigurableTransactionManager,org.springframework.transaction.PlatformTransactionManager,org.springframework.transaction.support.ResourceTransactionManager,org.springframework.transaction.TransactionManager
PlatformTransactionManager for Litebridge.
This class extends DataSourceTransactionManager to provide standard JDBC transaction management
while implementing Litebridge's TransactionManager interface to allow Litebridge to participate
in Spring-managed transactions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.transaction.support.AbstractPlatformTransactionManager.SuspendedResourcesHolder -
Field Summary
Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommitCallback(Runnable callback) Adds aRunnableto be executed if the transaction is committed.voidaddRollbackCallback(Runnable callback) Adds aRunnableto be executed if the transaction is rolled back.voidbegin()Begins a new transaction for the current thread.voidvoidcleanup()Performs cleanup operations for the transaction manager, releasing any resources held.voidcommit()Commits the current transaction.Provides a transaction-bound managed connection to the underlying database.booleanChecks if the current transaction is marked as rollback-only.booleanChecks if there is an active transaction for the current thread.booleanIndicates whether cleanup operations are yet to be performed for the transaction manager (i.e. whether the manager itself "active" and holding onto resources).voidrollback()Rolls back the current transaction.Methods inherited from class org.springframework.jdbc.datasource.DataSourceTransactionManager
afterPropertiesSet, doBegin, doCleanupAfterCompletion, doCommit, doGetTransaction, doResume, doRollback, doSetRollbackOnly, doSuspend, getDataSource, getResourceFactory, isEnforceReadOnly, isExistingTransaction, obtainDataSource, prepareTransactionalConnection, setDataSource, setEnforceReadOnly, translateExceptionMethods inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
commit, determineTimeout, getDefaultTimeout, getTransaction, getTransactionExecutionListeners, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, prepareForCommit, prepareSynchronization, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionExecutionListeners, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, shouldCommitOnGlobalRollbackOnly, suspend, triggerBeforeCommit, triggerBeforeCompletion, useSavepointForNestedTransactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.transaction.ConfigurableTransactionManager
addListenerMethods inherited from interface org.springframework.transaction.PlatformTransactionManager
commit, getTransaction, rollback
-
Constructor Details
-
LitebridgeTransactionManager
-
-
Method Details
-
begin
Description copied from interface:TransactionManagerBegins a new transaction for the current thread.This method should be called before performing operations that need to be executed within a transactional context. It ensures that subsequent database interactions are part of the same transaction until it is either committed or rolled back.
This method may be called multiple times (nested).
- Specified by:
beginin interfaceTransactionManager- Throws:
TransactionException- if an error occurs during starting the transaction
-
begin
- Specified by:
beginin interfaceTransactionManager- Throws:
TransactionException
-
cleanup
Description copied from interface:TransactionManagerPerforms cleanup operations for the transaction manager, releasing any resources held. This method should be called when the transaction manager is no longer needed to ensure proper resource management.This method is idempotent; subsequent calls do nothing after the first cleanup.
This is typically called directly by implementations of
TransactionControl.commit()andTransactionControl.rollback().- Specified by:
cleanupin interfaceTransactionManager- Throws:
TransactionException- if an error occurs during cleanup operations
-
requiresCleanup
public boolean requiresCleanup()Description copied from interface:TransactionManagerIndicates whether cleanup operations are yet to be performed for the transaction manager (i.e. whether the manager itself "active" and holding onto resources).This method returns
trueif cleanup still needs to be performed,falseotherwise.- Specified by:
requiresCleanupin interfaceTransactionManager- Returns:
trueif cleanup still needs to be performed,falseotherwise
-
addCommitCallback
Description copied from interface:TransactionManagerAdds aRunnableto be executed if the transaction is committed.- Specified by:
addCommitCallbackin interfaceTransactionManager- Parameters:
callback- The runnable to execute when the transaction is committed.
-
addRollbackCallback
Description copied from interface:TransactionManagerAdds aRunnableto be executed if the transaction is rolled back.- Specified by:
addRollbackCallbackin interfaceTransactionManager- Parameters:
callback- The runnable to execute on transaction rollback.
-
commit
Description copied from interface:TransactionControlCommits the current transaction.This method finalises all operations performed during the transaction and applies any changes to the underlying database. After a successful commit, the transaction is no longer active.
- Specified by:
commitin interfaceTransactionControl- Throws:
TransactionException- if an error occurs during the commit processIllegalStateException- if there is no active transaction to commit
-
rollback
Description copied from interface:TransactionControlRolls back the current transaction.This method undoes all changes made during the active transaction. It reverts the state of the underlying data store to the point before the transaction began. After a successful rollback, the transaction is no longer active.
It should be called in cases where the transaction cannot be successfully completed, such as when an error occurs during the operations performed within the transaction.
- Specified by:
rollbackin interfaceTransactionControl- Throws:
TransactionException- if an error occurs during the rollback processIllegalStateException- if there is no active transaction to roll back
-
isTransactionActive
public boolean isTransactionActive()Description copied from interface:TransactionControlChecks if there is an active transaction for the current thread.This method determines whether a transaction has been started and is not yet committed or rolled back.
- Specified by:
isTransactionActivein interfaceTransactionControl- Returns:
trueif a thread-bound transaction is currently active,falseotherwise
-
isRollbackOnly
public boolean isRollbackOnly()Description copied from interface:TransactionControlChecks if the current transaction is marked as rollback-only. This indicates that the transaction cannot be successfully committed and must be rolled back.- Specified by:
isRollbackOnlyin interfaceTransactionControl- Returns:
trueif the transaction is marked for rollback,falseotherwise
-
connection
Description copied from interface:ConnectionProviderProvides a transaction-bound managed connection to the underlying database.This method is typically used to execute database operations within the context of the current transaction (or not, if the connection is in auto-commit mode).
Transactions themselves (and corresponding
Connectionlifecycle methods) are managed by aTransactionManagerand are not supported by the returnedManagedConnection.- Specified by:
connectionin interfaceConnectionProvider- Returns:
- a
ManagedConnectioninstance representing the database connection - Throws:
SQLException- if an error occurs while obtaining the connection
-