Class JTATransactionController
- All Implemented Interfaces:
- ExternalTransactionController
- Direct Known Subclasses:
- GlassfishTransactionController,- JBossTransactionController,- JotmTransactionController,- JTA11TransactionController,- Oc4jTransactionController,- SAPNetWeaverTransactionController,- WebLogicTransactionController,- WebSphereTransactionController
Purpose: TransactionController implementation for JTA 1.0
Description: Implements the required behavior for controlling JTA 1.0 transactions. Specific JTA implementations may need to extend this class when special controller behavior is necessary.
The JTA TransactionManager must be obtained and set on the instance in order for a Synchronization listener to be registered against the transaction. This can be done either by extending this class and defining acquireTransactionManager() to return the manager for the server, or by using this class and explicitly calling the setTransactionManager() method on it after the fact. e.g. TransactionManager mgr = controller.jndiLookup("java:comp/TransactionManager"); controller.setTransactionManager(mgr);
If a different listener needs to be used for synchronization, the SynchronizationListenerFactory should be set on the controller instance. The listener subclass should implement the factory interface, so that setting the factory is simply a matter of assigning an instance of the listener. e.g. controller.setSynchronizationListenerFactory( new DifferentServerSynchronizationListener()); The default listener factory creates instances of JTATransactionListener.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static jakarta.transaction.TransactionManagerprotected jakarta.transaction.TransactionManagerFields inherited from class org.eclipse.persistence.transaction.AbstractTransactionControlleractiveUnitOfWorkThreadLocal, currentlyProcessedListeners, exceptionHandler, listenerFactory, numSessionsRequiringSequencingCallback, sequencingListeners, session, unitsOfWork
- 
Constructor SummaryConstructorsConstructorDescriptionPUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.JTATransactionController(jakarta.transaction.TransactionManager transactionManager) PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.
- 
Method SummaryModifier and TypeMethodDescriptionprotected jakarta.transaction.TransactionManagerINTERNAL: Obtain and return the JTA TransactionManager on this platform.protected voidINTERNAL: Begin an external transaction.protected booleancanBeginTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be started.protected booleancanCommitTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be committed.protected booleancanIssueSQLToDatabase_impl(Object status) INTERNAL: Return true if the status indicates that the SQL should be issued to the db.protected booleancanMergeUnitOfWork_impl(Object status) INTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache.protected booleancanRollbackTransaction_impl(Object status) INTERNAL: Return true if the status indicates that a transaction can be rolled back.protected voidINTERNAL: Commit the external transaction.static jakarta.transaction.TransactionManagerprotected intgetIntStatus(Object status) INTERNAL: Convenience method to return the int value of the transaction status.protected ObjectINTERNAL: Return the active external transaction, or null if none is currently active for this thread.protected ObjectgetTransactionKey_impl(Object transaction) INTERNAL: Return a key for the specified external transaction object.jakarta.transaction.TransactionManagerPUBLIC: Return the transaction manager used to control the JTA transactions.protected ObjectINTERNAL: Return the transaction status as an object.booleanisRolledBack_impl(Object status) INTERNAL: Return true if the transaction is rolled back.protected voidINTERNAL: Mark the external transaction for rollback.protected voidregisterSynchronization_impl(AbstractSynchronizationListener listener, Object txn) INTERNAL: Register the specified synchronization listener with the given active transaction.protected voidINTERNAL: Roll back the external transaction.static voidsetDefaultTransactionManager(jakarta.transaction.TransactionManager defaultTransactionManager) PUBLIC: Set the JTA transaction manager to be used.voidsetTransactionManager(jakarta.transaction.TransactionManager mgr) PUBLIC: Set the transaction manager used to control the JTA transactions.protected StringstatusToString_impl(Object status) INTERNAL: Convert the status to a string for tracing.Methods inherited from class org.eclipse.persistence.transaction.AbstractTransactionControlleraddUnitOfWork, beginTransaction, bindToCurrentTransaction, clearSequencingListeners, commitTransaction, getActiveSequencingCallback, getActiveUnitOfWork, getExceptionHandler, getListenerFactory, getSession, getTransaction, getTransactionKey, getTransactionStatus, getUnitsOfWork, hasActiveUnitOfWork, initializeSequencingListeners, isSequencingCallbackRequired, jndiLookup, logTxStateTrace, logTxTrace, lookupActiveUnitOfWork, lookupActiveUnitOfWork, markTransactionForRollback, noTransactionOrRolledBackOrCommited, numSessionsRequiringSequencingCallback, registerSynchronizationListener, removeSequencingListener, removeUnitOfWork, rollbackTransaction, setExceptionHandler, setListenerFactory, setSession, setUnitsOfWork
- 
Field Details- 
defaultTransactionManagerprotected static jakarta.transaction.TransactionManager defaultTransactionManager
- 
transactionManagerprotected jakarta.transaction.TransactionManager transactionManager
 
- 
- 
Constructor Details- 
JTATransactionControllerpublic JTATransactionController()PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.
- 
JTATransactionControllerpublic JTATransactionController(jakarta.transaction.TransactionManager transactionManager) PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.
 
- 
- 
Method Details- 
registerSynchronization_implprotected void registerSynchronization_impl(AbstractSynchronizationListener listener, Object txn) throws Exception INTERNAL: Register the specified synchronization listener with the given active transaction.- Specified by:
- registerSynchronization_implin class- AbstractTransactionController
- Parameters:
- listener- The synchronization listener created for this transaction
- txn- The active transaction for which notification is being requested
- Throws:
- Exception
 
- 
getTransaction_implINTERNAL: Return the active external transaction, or null if none is currently active for this thread.- Specified by:
- getTransaction_implin class- AbstractTransactionController
- Returns:
- The active transaction object or id, or null if no transaction is active
- Throws:
- Exception
 
- 
getTransactionKey_implINTERNAL: Return a key for the specified external transaction object. The key is just something that can be inserted into a hashtable (must support hashCode() and equals() methods).- Specified by:
- getTransactionKey_implin class- AbstractTransactionController
- Parameters:
- transaction- The transaction to which the returned key applies (may be null)
- Returns:
- A key for the passed in transaction, or null if no transaction specified
- Throws:
- Exception
 
- 
getTransactionStatus_implINTERNAL: Return the transaction status as an object. We will pass around Integers that wrap the int JTA status values.- Specified by:
- getTransactionStatus_implin class- AbstractTransactionController
- Returns:
- The current transaction status
- Throws:
- Exception
 
- 
beginTransaction_implINTERNAL: Begin an external transaction.- Specified by:
- beginTransaction_implin class- AbstractTransactionController
- Throws:
- Exception
 
- 
commitTransaction_implINTERNAL: Commit the external transaction.- Specified by:
- commitTransaction_implin class- AbstractTransactionController
- Throws:
- Exception
 
- 
rollbackTransaction_implINTERNAL: Roll back the external transaction.- Specified by:
- rollbackTransaction_implin class- AbstractTransactionController
- Throws:
- Exception
 
- 
markTransactionForRollback_implINTERNAL: Mark the external transaction for rollback.- Specified by:
- markTransactionForRollback_implin class- AbstractTransactionController
- Throws:
- Exception
 
- 
canBeginTransaction_implINTERNAL: Return true if the status indicates that a transaction can be started. This would normally mean that no transaction is currently active.- Specified by:
- canBeginTransaction_implin class- AbstractTransactionController
- Parameters:
- status- The current transaction status
- Returns:
- true if the current state allows for a transaction to be started
 
- 
canCommitTransaction_implINTERNAL: Return true if the status indicates that a transaction can be committed. This would normally mean that a transaction is currently active.- Specified by:
- canCommitTransaction_implin class- AbstractTransactionController
- Parameters:
- status- The current transaction status
- Returns:
- true if the current state allows for a transaction to be committed
 
- 
canRollbackTransaction_implINTERNAL: Return true if the status indicates that a transaction can be rolled back. This would normally mean that a transaction is currently active.- Specified by:
- canRollbackTransaction_implin class- AbstractTransactionController
- Parameters:
- status- The current transaction status
- Returns:
- true if the current state allows for a transaction to be rolled back
 
- 
canIssueSQLToDatabase_implINTERNAL: Return true if the status indicates that the SQL should be issued to the db. This would normally mean that a transaction was active.- Specified by:
- canIssueSQLToDatabase_implin class- AbstractTransactionController
- Parameters:
- status- The current transaction status
- Returns:
- true if the current state allows for the SQL to be sent to the database
 
- 
canMergeUnitOfWork_implINTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache. This would normally mean that the transaction was committed successfully.- Specified by:
- canMergeUnitOfWork_implin class- AbstractTransactionController
- Parameters:
- status- The current transaction status
- Returns:
- true if the current state dictates that the unit of work should be merged
 
- 
isRolledBack_implINTERNAL: Return true if the transaction is rolled back.- Specified by:
- isRolledBack_implin class- AbstractTransactionController
 
- 
acquireTransactionManagerINTERNAL: Obtain and return the JTA TransactionManager on this platform. By default try java:comp JNDI lookup. This method can be can be overridden by subclasses to obtain the transaction manager by whatever means is appropriate to the server. This method is invoked by the constructor to initialize the transaction manager at instance-creation time. Alternatively the transaction manager can be set directly on the controller instance using the setTransactionManager() method after the instance has been created.- Returns:
- The TransactionManager for the transaction system
- Throws:
- Exception
 
- 
getIntStatusINTERNAL: Convenience method to return the int value of the transaction status. Assumes that the status object is an Integer.
- 
getTransactionManagerpublic jakarta.transaction.TransactionManager getTransactionManager()PUBLIC: Return the transaction manager used to control the JTA transactions.- Returns:
- The JTA TransactionManager that is used to obtain transaction state information and control the active transaction.
 
- 
setTransactionManagerpublic void setTransactionManager(jakarta.transaction.TransactionManager mgr) PUBLIC: Set the transaction manager used to control the JTA transactions.- Parameters:
- mgr- A valid JTA TransactionManager that can be accessed by this controller to obtain transaction state information and control the active transaction.
 
- 
statusToString_implDescription copied from class:AbstractTransactionControllerINTERNAL: Convert the status to a string for tracing.- Specified by:
- statusToString_implin class- AbstractTransactionController
 
- 
getDefaultTransactionManagerpublic static jakarta.transaction.TransactionManager getDefaultTransactionManager()
- 
setDefaultTransactionManagerpublic static void setDefaultTransactionManager(jakarta.transaction.TransactionManager defaultTransactionManager) PUBLIC: Set the JTA transaction manager to be used. This can be called directly before login to configure JTA integration manually, or using Spring injection.
 
-