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 TransactionSynchronizationRegistry | defaultTsr
Allows |
| public static final String | JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY
Common JNDI name of |
| protected TransactionSynchronizationRegistry | tsr
Primary point of integration with JTA 1.1. |
| Access | Constructor and Description |
|---|---|
| public | JTA11TransactionController()
PUBLIC:
Return a new controller for use with acquired JTA 1.1 compliant |
| public | JTA11TransactionController(final TransactionSynchronizationRegistry
supplied JTA 1.1 compliant synchronization objects registry supplTsr, final TransactionManager supplied JTA 1.0 compliant transaction manager. supplTm)PUBLIC: Return a new controller for use with supplied JTA 1.1 compliant synchronization objects registry. |
| Modifier and Type | Method and Description |
|---|---|
| protected TransactionSynchronizationRegistry | Returns: theTransactionSynchronizationRegistry for the transaction system or null
if no default value was foundINTERNAL:
Obtain and return the JTA 1.1 |
| public static TransactionSynchronizationRegistry | Returns: synchronization objects registry being used ornull if no default value was set yet.PUBLIC: Get the default JTA 1.1 synchronization objects registry being used. |
| protected Object | Returns: an opaque object to represent the transaction bound to the current thread at the time this method is called, ornull if no transaction specifiedThe transaction to which the returned key applies (may be null) transaction)Overrides org. |
| protected Object | Returns: the status of the transaction bound to the current thread at the time this method is calledOverrides org. |
| public TransactionSynchronizationRegistry | Returns: the JTA 1.1TransactionSynchronizationRegistry that is used to obtain transaction
state information and control the active transactionPUBLIC: Return the synchronization objects registry used to control the JTA 1.1 transactions. |
| public boolean | isRolledBack_impl(final Object
true if the transaction is rolled back or false otherwiseOverrides org. |
| protected void | markTransactionForRollback_impl()
Overrides org. |
| protected void | registerSynchronization_impl(final AbstractSynchronizationListener
the synchronization listener created for this transaction listener, final Object the active transaction for which notification is being requested txn)Overrides org. |
| public static void | setDefaultTransactionSynchronizationRegistry(final TransactionSynchronizationRegistry
synchronization objects registry to set tsr)PUBLIC: Set the default JTA 1.1 synchronization objects registry to be used. |
| public void | setTransactionManager(final TransactionSynchronizationRegistry
a valid JTA 1.1 supplTsr)TransactionSynchronizationRegistry that can be accessed by this controller
to obtain transaction state information and control the active transactionPUBLIC: Set the synchronization objects registry used to control the JTA 1.1 transactions. |
| defaultTsr | back to summary |
|---|---|
| protected static TransactionSynchronizationRegistry defaultTsr Allows | |
| JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY | back to summary |
|---|---|
| public static final String JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY Common JNDI name of | |
| tsr | back to summary |
|---|---|
| protected TransactionSynchronizationRegistry tsr Primary point of integration with JTA 1.1. | |
| JTA11TransactionController | back to summary |
|---|---|
| public JTA11TransactionController() PUBLIC:
Return a new controller for use with acquired JTA 1.1 compliant | |
| JTA11TransactionController | back to summary |
|---|---|
| public JTA11TransactionController(final TransactionSynchronizationRegistry supplTsr, final TransactionManager supplTm) PUBLIC: Return a new controller for use with supplied JTA 1.1 compliant synchronization objects registry.
| |
| acquireTransactionSynchronizationRegistry | back to summary |
|---|---|
| protected TransactionSynchronizationRegistry acquireTransactionSynchronizationRegistry() INTERNAL:
Obtain and return the JTA 1.1
| |
| getDefaultTransactionSynchronizationRegistry | back to summary |
|---|---|
| public static TransactionSynchronizationRegistry getDefaultTransactionSynchronizationRegistry() PUBLIC: Get the default JTA 1.1 synchronization objects registry being used.
| |
| getTransactionKey_impl | back to summary |
|---|---|
| protected Object getTransactionKey_impl(final Object transaction) throws Exception Overrides org. INTERNAL:
Return a key for the specified external transaction object.
The key is just something that can be inserted into a hash table (must support | |
| getTransactionStatus_impl | back to summary |
|---|---|
| protected Object getTransactionStatus_impl() throws Exception Overrides org. INTERNAL:
Return the transaction status as an object. We will pass around | |
| getTransactionSynchronizationRegistry | back to summary |
|---|---|
| public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() PUBLIC: Return the synchronization objects registry used to control the JTA 1.1 transactions.
| |
| isRolledBack_impl | back to summary |
|---|---|
| public boolean isRolledBack_impl(final Object status) Overrides org. INTERNAL: Check whether the transaction is rolled back. | |
| markTransactionForRollback_impl | back to summary |
|---|---|
| protected void markTransactionForRollback_impl() throws Exception Overrides org. INTERNAL: Mark the external transaction for rollback.
| |
| registerSynchronization_impl | back to summary |
|---|---|
| protected void registerSynchronization_impl(final AbstractSynchronizationListener listener, final Object txn) throws Exception Overrides org. INTERNAL: Register the specified synchronization listener with the given active transaction.
| |
| setDefaultTransactionSynchronizationRegistry | back to summary |
|---|---|
| public static void setDefaultTransactionSynchronizationRegistry(final TransactionSynchronizationRegistry tsr) PUBLIC: Set the default JTA 1.1 synchronization objects registry to be used. This can be called directly before login to configure JTA integration manually, or using Spring injection.
| |
| setTransactionManager | back to summary |
|---|---|
| public void setTransactionManager(final TransactionSynchronizationRegistry supplTsr) PUBLIC: Set the synchronization objects registry used to control the JTA 1.1 transactions.
| |