Class TransactionManager
- java.lang.Object
-
- io.ebeaninternal.server.transaction.TransactionManager
-
- All Implemented Interfaces:
SpiTransactionManager
- Direct Known Subclasses:
DocStoreTransactionManager
public class TransactionManager extends Object implements SpiTransactionManager
Manages transactions.Keeps the Cache and Cluster in sync when transactions are committed.
-
-
Constructor Summary
Constructors Constructor Description TransactionManager(TransactionManagerOptions options)
Create the TransactionManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScopedTransaction
beginScopedTransaction(TxScope txScope)
Begin a scoped transaction.SpiTransaction
beginServerTransaction()
Begin an implicit transaction.void
clearServerTransaction()
Clear an implicit transaction from thread local scope.SpiTransaction
createReadOnlyTransaction(Object tenantId)
Create a new Transaction for query only purposes (can use read only datasource).SpiTransaction
createTransaction(boolean explicit, int isolationLevel)
Create a new Transaction.void
exitScopedTransaction(Object returnOrThrowable, int opCode)
Exit a scoped transaction (that can be inactive - already committed etc).ScopedTransaction
externalBeginTransaction(SpiTransaction transaction, TxScope txScope)
Push an externally created transaction into scope.void
externalModification(TransactionEventTable tableEvent)
void
externalRemoveTransaction()
Called when an externally managed transaction has completed.SpiTransaction
getActive()
Return the current active transaction.BeanDescriptorManager
getBeanDescriptorManager()
DataSource
getDataSource()
Return the main DataSource.SpiTransaction
getInScope()
Return the current transaction from thread local scope.boolean
getPersistBatchOnCascade()
Connection
getQueryPlanConnection()
Return a connection used for query plan collection.DataSource
getReadOnlyDataSource()
Return the read only DataSource (if defined).String
getServerName()
boolean
isLogSql()
boolean
isLogSummary()
boolean
isTxnDebug()
Return true if Transaction debug is on.SpiLogManager
log()
void
notifyOfCommit(SpiTransaction transaction)
Process a local committed transaction.void
notifyOfQueryOnly(SpiTransaction transaction)
Query only transaction in read committed isolation.void
notifyOfRollback(SpiTransaction transaction, Throwable cause)
Process a local rolled back transaction.void
remoteTransactionEvent(RemoteTransactionEvent remoteEvent)
Notify local BeanPersistListeners etc of events from another server in the cluster.TransactionScopeManager
scope()
Return the scope manager.void
set(SpiTransaction txn)
Set the transaction onto the scope.void
shutdown(boolean shutdownDataSource, boolean deregisterDriver)
javax.persistence.PersistenceException
translate(String message, SQLException cause)
Translate the SQLException into a specific exception if possible based on the DB platform.void
visitMetrics(MetricVisitor visitor)
SpiTransaction
wrapExternalConnection(Connection c)
Wrap the externally supplied Connection.
-
-
-
Constructor Detail
-
TransactionManager
public TransactionManager(TransactionManagerOptions options)
Create the TransactionManager
-
-
Method Detail
-
scope
public TransactionScopeManager scope()
Return the scope manager.- Specified by:
scope
in interfaceSpiTransactionManager
-
set
public void set(SpiTransaction txn)
Set the transaction onto the scope.
-
getActive
public SpiTransaction getActive()
Return the current active transaction.- Specified by:
getActive
in interfaceSpiTransactionManager
-
getInScope
public SpiTransaction getInScope()
Return the current transaction from thread local scope. Note that it may be inactive.
-
translate
public javax.persistence.PersistenceException translate(String message, SQLException cause)
Translate the SQLException into a specific exception if possible based on the DB platform.
-
shutdown
public void shutdown(boolean shutdownDataSource, boolean deregisterDriver)
-
getBeanDescriptorManager
public BeanDescriptorManager getBeanDescriptorManager()
-
getPersistBatchOnCascade
public boolean getPersistBatchOnCascade()
-
getServerName
public String getServerName()
-
getQueryPlanConnection
public Connection getQueryPlanConnection() throws SQLException
Description copied from interface:SpiTransactionManager
Return a connection used for query plan collection.- Specified by:
getQueryPlanConnection
in interfaceSpiTransactionManager
- Throws:
SQLException
-
getDataSource
public DataSource getDataSource()
Description copied from interface:SpiTransactionManager
Return the main DataSource.- Specified by:
getDataSource
in interfaceSpiTransactionManager
-
getReadOnlyDataSource
public DataSource getReadOnlyDataSource()
Description copied from interface:SpiTransactionManager
Return the read only DataSource (if defined).- Specified by:
getReadOnlyDataSource
in interfaceSpiTransactionManager
-
wrapExternalConnection
public SpiTransaction wrapExternalConnection(Connection c)
Wrap the externally supplied Connection.
-
createTransaction
public SpiTransaction createTransaction(boolean explicit, int isolationLevel)
Create a new Transaction.
-
createReadOnlyTransaction
public SpiTransaction createReadOnlyTransaction(Object tenantId)
Create a new Transaction for query only purposes (can use read only datasource).
-
notifyOfRollback
public void notifyOfRollback(SpiTransaction transaction, Throwable cause)
Process a local rolled back transaction.- Specified by:
notifyOfRollback
in interfaceSpiTransactionManager
-
notifyOfQueryOnly
public void notifyOfQueryOnly(SpiTransaction transaction)
Query only transaction in read committed isolation.- Specified by:
notifyOfQueryOnly
in interfaceSpiTransactionManager
-
notifyOfCommit
public void notifyOfCommit(SpiTransaction transaction)
Process a local committed transaction.- Specified by:
notifyOfCommit
in interfaceSpiTransactionManager
-
externalModification
public void externalModification(TransactionEventTable tableEvent)
-
remoteTransactionEvent
public void remoteTransactionEvent(RemoteTransactionEvent remoteEvent)
Notify local BeanPersistListeners etc of events from another server in the cluster.
-
visitMetrics
public void visitMetrics(MetricVisitor visitor)
-
clearServerTransaction
public void clearServerTransaction()
Clear an implicit transaction from thread local scope.
-
beginServerTransaction
public SpiTransaction beginServerTransaction()
Begin an implicit transaction.
-
exitScopedTransaction
public void exitScopedTransaction(Object returnOrThrowable, int opCode)
Exit a scoped transaction (that can be inactive - already committed etc).
-
externalRemoveTransaction
public void externalRemoveTransaction()
Description copied from interface:SpiTransactionManager
Called when an externally managed transaction has completed.- Specified by:
externalRemoveTransaction
in interfaceSpiTransactionManager
-
externalBeginTransaction
public ScopedTransaction externalBeginTransaction(SpiTransaction transaction, TxScope txScope)
Push an externally created transaction into scope. This transaction is usually managed externally (e.g. Spring managed transaction).- Specified by:
externalBeginTransaction
in interfaceSpiTransactionManager
-
beginScopedTransaction
public ScopedTransaction beginScopedTransaction(TxScope txScope)
Begin a scoped transaction.
-
isTxnDebug
public boolean isTxnDebug()
Return true if Transaction debug is on.
-
log
public SpiLogManager log()
-
isLogSql
public boolean isLogSql()
-
isLogSummary
public boolean isLogSummary()
-
-