public class JTA11TransactionController extends JTATransactionController
Purpose: TransactionController extensions for JTA 1.1
Description: Implements the required behavior for controlling JTA 1.1 transactions. Specific JTA implementations may need to extend this class when special controller behavior is necessary.
The JTA TransactionSynchronizationRegistry
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
acquireTransactionSynchronizationRegistry()
to return the manager for the server, or by using
this class and explicitly calling the setTransactionSynchronizationRegistry()
method on it
after the fact.
e.g.
TransactionSynchronizationRegistry tsr = controller.jndiLookup("java:comp/setTransactionSynchronizationRegistry");
controller.setTransactionManager(tsr);
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
.
JTASynchronizationListener
,
AbstractTransactionController
Modifier and Type | Field and Description |
---|---|
protected static jakarta.transaction.TransactionSynchronizationRegistry |
defaultTsr
Allows
TransactionSynchronizationRegistry to be set statically. |
static String |
JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY
Common JNDI name of
TransactionSynchronizationRegistry instance. |
protected jakarta.transaction.TransactionSynchronizationRegistry |
tsr
Primary point of integration with JTA 1.1.
|
defaultTransactionManager, transactionManager
activeUnitOfWorkThreadLocal, currentlyProcessedListeners, exceptionHandler, listenerFactory, numSessionsRequiringSequencingCallback, sequencingListeners, session, unitsOfWork
Constructor and Description |
---|
JTA11TransactionController()
PUBLIC:
Return a new controller for use with acquired JTA 1.1 compliant
TransactionSynchronizationRegistry . |
JTA11TransactionController(jakarta.transaction.TransactionSynchronizationRegistry supplTsr,
jakarta.transaction.TransactionManager supplTm)
PUBLIC:
Return a new controller for use with supplied JTA 1.1 compliant synchronization objects registry.
|
Modifier and Type | Method and Description |
---|---|
protected jakarta.transaction.TransactionSynchronizationRegistry |
acquireTransactionSynchronizationRegistry()
INTERNAL:
Obtain and return the JTA 1.1
TransactionSynchronizationRegistry on this platform. |
static jakarta.transaction.TransactionSynchronizationRegistry |
getDefaultTransactionSynchronizationRegistry()
PUBLIC:
Get the default JTA 1.1 synchronization objects registry being used.
|
protected Object |
getTransactionKey_impl(Object transaction)
INTERNAL:
Return a key for the specified external transaction object.
|
protected Object |
getTransactionStatus_impl()
INTERNAL:
Return the transaction status as an object.
|
jakarta.transaction.TransactionSynchronizationRegistry |
getTransactionSynchronizationRegistry()
PUBLIC:
Return the synchronization objects registry used to control the JTA 1.1 transactions.
|
boolean |
isRolledBack_impl(Object status)
INTERNAL:
Check whether the transaction is rolled back.
|
protected void |
markTransactionForRollback_impl()
INTERNAL:
Mark the external transaction for rollback.
|
protected void |
registerSynchronization_impl(AbstractSynchronizationListener listener,
Object txn)
INTERNAL:
Register the specified synchronization listener with the given active transaction.
|
static void |
setDefaultTransactionSynchronizationRegistry(jakarta.transaction.TransactionSynchronizationRegistry tsr)
PUBLIC:
Set the default JTA 1.1 synchronization objects registry to be used.
|
void |
setTransactionManager(jakarta.transaction.TransactionSynchronizationRegistry supplTsr)
PUBLIC:
Set the synchronization objects registry used to control the JTA 1.1 transactions.
|
acquireTransactionManager, beginTransaction_impl, canBeginTransaction_impl, canCommitTransaction_impl, canIssueSQLToDatabase_impl, canMergeUnitOfWork_impl, canRollbackTransaction_impl, commitTransaction_impl, getDefaultTransactionManager, getIntStatus, getTransaction_impl, getTransactionManager, rollbackTransaction_impl, setDefaultTransactionManager, setTransactionManager, statusToString_impl
addUnitOfWork, 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
public static final String JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY
TransactionSynchronizationRegistry
instance.protected static jakarta.transaction.TransactionSynchronizationRegistry defaultTsr
TransactionSynchronizationRegistry
to be set statically.protected jakarta.transaction.TransactionSynchronizationRegistry tsr
public JTA11TransactionController()
TransactionSynchronizationRegistry
.public JTA11TransactionController(jakarta.transaction.TransactionSynchronizationRegistry supplTsr, jakarta.transaction.TransactionManager supplTm)
supplTm
- supplied JTA 1.0 compliant transaction manager.supplTsr
- supplied JTA 1.1 compliant synchronization objects registrypublic static jakarta.transaction.TransactionSynchronizationRegistry getDefaultTransactionSynchronizationRegistry()
null
if no default value was set yet.public static void setDefaultTransactionSynchronizationRegistry(jakarta.transaction.TransactionSynchronizationRegistry tsr)
tsr
- synchronization objects registry to setprotected jakarta.transaction.TransactionSynchronizationRegistry acquireTransactionSynchronizationRegistry()
TransactionSynchronizationRegistry
on this platform.
This method can be can be overridden by subclasses to obtain the
TransactionSynchronizationRegistry
by whatever means is appropriate to the server.
This method is invoked by the constructor to initialize the synchronization objects registry
at instance-creation time. Alternatively the synchronization objects registry
can be set directly on the controller instance using the setTransactionManager() method
after the instance has been created.TransactionSynchronizationRegistry
for the transaction system or null
if no default value was foundpublic jakarta.transaction.TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
TransactionSynchronizationRegistry
that is used to obtain transaction
state information and control the active transactionpublic void setTransactionManager(jakarta.transaction.TransactionSynchronizationRegistry supplTsr)
supplTsr
- a valid JTA 1.1 TransactionSynchronizationRegistry
that can be accessed by this controller
to obtain transaction state information and control the active transactionprotected void registerSynchronization_impl(AbstractSynchronizationListener listener, Object txn) throws Exception
registerSynchronization_impl
in class JTATransactionController
listener
- the synchronization listener created for this transactiontxn
- the active transaction for which notification is being requestedException
protected Object getTransactionKey_impl(Object transaction) throws Exception
hashCode()
and equals()
methods).getTransactionKey_impl
in class JTATransactionController
transaction
- The transaction to which the returned key applies (may be null)null
if no transaction specifiedException
protected Object getTransactionStatus_impl() throws Exception
Integer
s that wrap the int
JTA status values.getTransactionStatus_impl
in class JTATransactionController
Exception
protected void markTransactionForRollback_impl() throws Exception
markTransactionForRollback_impl
in class JTATransactionController
Exception
public boolean isRolledBack_impl(Object status)
isRolledBack_impl
in class JTATransactionController
status
- true
if the transaction is rolled back or false
otherwiseCopyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.