Top Description Fields Constructors Methods
org.eclipse.persistence.transaction

public Class JTA11TransactionController

extends JTATransactionController
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.transaction.glassfish.GlassfishTransactionController11, org.eclipse.persistence.transaction.jboss.JBossTransactionController11, org.eclipse.persistence.transaction.wls.WebLogicTransactionController11, org.eclipse.persistence.transaction.wildfly.WildFlyTransactionController11
Imports
jakarta.transaction.TransactionManager, .TransactionSynchronizationRegistry, org.eclipse.persistence.exceptions.TransactionException, org.eclipse.persistence.logging.SessionLog

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.

Since
2.7.1
See Also
JTASynchronizationListener, AbstractTransactionController

Field Summary

Modifier and TypeField and Description
protected static TransactionSynchronizationRegistry
defaultTsr

Allows TransactionSynchronizationRegistry to be set statically.

public static final String
JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY

Common JNDI name of TransactionSynchronizationRegistry instance.

protected TransactionSynchronizationRegistry
tsr

Primary point of integration with JTA 1.1.

Inherited from org.eclipse.persistence.transaction.JTATransactionController:
codesdefaultTransactionManagertransactionManager

Constructor Summary

AccessConstructor and Description
public
JTA11TransactionController()

PUBLIC: Return a new controller for use with acquired JTA 1.1 compliant TransactionSynchronizationRegistry.

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.

Method Summary

Modifier and TypeMethod and Description
protected TransactionSynchronizationRegistry

Returns:

the TransactionSynchronizationRegistry for the transaction system or null if no default value was found
acquireTransactionSynchronizationRegistry
()

INTERNAL: Obtain and return the JTA 1.1 TransactionSynchronizationRegistry on this platform.

public static TransactionSynchronizationRegistry

Returns:

synchronization objects registry being used or null if no default value was set yet.
getDefaultTransactionSynchronizationRegistry
()

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, or null if no transaction specified
getTransactionKey_impl
(final Object
The transaction to which the returned key applies (may be null)
transaction
)

Overrides org.eclipse.persistence.transaction.JTATransactionController.getTransactionKey_impl.

INTERNAL: Return a key for the specified external transaction object.
protected Object

Returns:

the status of the transaction bound to the current thread at the time this method is called
getTransactionStatus_impl
()

Overrides org.eclipse.persistence.transaction.JTATransactionController.getTransactionStatus_impl.

INTERNAL: Return the transaction status as an object.
public TransactionSynchronizationRegistry

Returns:

the JTA 1.1 TransactionSynchronizationRegistry that is used to obtain transaction state information and control the active transaction
getTransactionSynchronizationRegistry
()

PUBLIC: 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 otherwise
status
)

Overrides org.eclipse.persistence.transaction.JTATransactionController.isRolledBack_impl.

INTERNAL: Check whether the transaction is rolled back.
protected void
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.eclipse.persistence.transaction.JTATransactionController.registerSynchronization_impl.

INTERNAL: Register the specified synchronization listener with the given active transaction.
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 TransactionSynchronizationRegistry that can be accessed by this controller to obtain transaction state information and control the active transaction
supplTsr
)

PUBLIC: Set the synchronization objects registry used to control the JTA 1.1 transactions.

Inherited from org.eclipse.persistence.transaction.JTATransactionController:
acquireTransactionManagerbeginTransaction_implcanBeginTransaction_implcanCommitTransaction_implcanIssueSQLToDatabase_implcanMergeUnitOfWork_implcanRollbackTransaction_implcommitTransaction_implgetDefaultTransactionManagergetIntStatusgetTransaction_implgetTransactionManagerrollbackTransaction_implsetDefaultTransactionManagersetTransactionManagerstatusToString_impl

Field Detail

defaultTsrback to summary
protected static TransactionSynchronizationRegistry defaultTsr

Allows TransactionSynchronizationRegistry to be set statically.

JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRYback to summary
public static final String JNDI_TRANSACTION_SYNCHRONIZATION_REGISTRY

Common JNDI name of TransactionSynchronizationRegistry instance.

tsrback to summary
protected TransactionSynchronizationRegistry tsr

Primary point of integration with JTA 1.1.

Constructor Detail

JTA11TransactionControllerback to summary
public JTA11TransactionController()

PUBLIC: Return a new controller for use with acquired JTA 1.1 compliant TransactionSynchronizationRegistry.

JTA11TransactionControllerback 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.

Parameters
supplTsr:TransactionSynchronizationRegistry

supplied JTA 1.1 compliant synchronization objects registry

supplTm:TransactionManager

supplied JTA 1.0 compliant transaction manager.

Method Detail

acquireTransactionSynchronizationRegistryback to summary
protected TransactionSynchronizationRegistry acquireTransactionSynchronizationRegistry()

INTERNAL: Obtain and return the JTA 1.1 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.

Returns:TransactionSynchronizationRegistry

the TransactionSynchronizationRegistry for the transaction system or null if no default value was found

getDefaultTransactionSynchronizationRegistryback to summary
public static TransactionSynchronizationRegistry getDefaultTransactionSynchronizationRegistry()

PUBLIC: Get the default JTA 1.1 synchronization objects registry being used.

Returns:TransactionSynchronizationRegistry

synchronization objects registry being used or null if no default value was set yet.

getTransactionKey_implback to summary
protected Object getTransactionKey_impl(final Object transaction) throws Exception

Overrides org.eclipse.persistence.transaction.JTATransactionController.getTransactionKey_impl.

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 hashCode() and equals() methods).

Parameters
transaction:Object

The transaction to which the returned key applies (may be null)

Returns:Object

an opaque object to represent the transaction bound to the current thread at the time this method is called, or null if no transaction specified

Annotations
@Override
getTransactionStatus_implback to summary
protected Object getTransactionStatus_impl() throws Exception

Overrides org.eclipse.persistence.transaction.JTATransactionController.getTransactionStatus_impl.

INTERNAL: Return the transaction status as an object. We will pass around Integers that wrap the int JTA status values.

Returns:Object

the status of the transaction bound to the current thread at the time this method is called

Annotations
@Override
getTransactionSynchronizationRegistryback to summary
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()

PUBLIC: Return the synchronization objects registry used to control the JTA 1.1 transactions.

Returns:TransactionSynchronizationRegistry

the JTA 1.1 TransactionSynchronizationRegistry that is used to obtain transaction state information and control the active transaction

isRolledBack_implback to summary
public boolean isRolledBack_impl(final Object status)

Overrides org.eclipse.persistence.transaction.JTATransactionController.isRolledBack_impl.

INTERNAL: Check whether the transaction is rolled back.

Parameters
status:Object

true if the transaction is rolled back or false otherwise

Annotations
@Override
markTransactionForRollback_implback to summary
protected void markTransactionForRollback_impl() throws Exception

Overrides org.eclipse.persistence.transaction.JTATransactionController.markTransactionForRollback_impl.

INTERNAL: Mark the external transaction for rollback.

Annotations
@Override
registerSynchronization_implback to summary
protected void registerSynchronization_impl(final AbstractSynchronizationListener listener, final Object txn) throws Exception

Overrides org.eclipse.persistence.transaction.JTATransactionController.registerSynchronization_impl.

INTERNAL: Register the specified synchronization listener with the given active transaction.

Parameters
listener:AbstractSynchronizationListener

the synchronization listener created for this transaction

txn:Object

the active transaction for which notification is being requested

Annotations
@Override
setDefaultTransactionSynchronizationRegistryback 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.

Parameters
tsr:TransactionSynchronizationRegistry

synchronization objects registry to set

setTransactionManagerback to summary
public void setTransactionManager(final TransactionSynchronizationRegistry supplTsr)

PUBLIC: Set the synchronization objects registry used to control the JTA 1.1 transactions.

Parameters
supplTsr:TransactionSynchronizationRegistry

a valid JTA 1.1 TransactionSynchronizationRegistry that can be accessed by this controller to obtain transaction state information and control the active transaction