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

public Class JTATransactionController

extends AbstractTransactionController
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.transaction.glassfish.GlassfishTransactionController, org.eclipse.persistence.transaction.jboss.JBossTransactionController, org.eclipse.persistence.transaction.sap.SAPNetWeaverTransactionController, org.eclipse.persistence.transaction.was.WebSphereTransactionController, org.eclipse.persistence.transaction.wls.WebLogicTransactionController, org.eclipse.persistence.transaction.jotm.JotmTransactionController, org.eclipse.persistence.transaction.wildfly.WildFlyTransactionController, org.eclipse.persistence.transaction.JTA11TransactionController
Imports
jakarta.transaction.*, org.eclipse.persistence.exceptions.TransactionException

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.

See Also
JTASynchronizationListener, AbstractTransactionController

Field Summary

Modifier and TypeField and Description
pack-priv static String[]
codes

INTERNAL: Convert the status to a string for tracing.

protected static TransactionManager
protected TransactionManager
Inherited from org.eclipse.persistence.transaction.AbstractTransactionController:
activeUnitOfWorkThreadLocalcurrentlyProcessedListenersexceptionHandlerlistenerFactorynumSessionsRequiringSequencingCallbacksequencingListenerssessionunitsOfWork

Constructor Summary

AccessConstructor and Description
public
JTATransactionController()

PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.

public
JTATransactionController(TransactionManager transactionManager)

PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.

Method Summary

Modifier and TypeMethod and Description
protected TransactionManager

Returns:

The TransactionManager for the transaction system
acquireTransactionManager
()

INTERNAL: Obtain and return the JTA TransactionManager on this platform.

protected void
protected boolean

Returns:

true if the current state allows for a transaction to be started
canBeginTransaction_impl
(Object
The current transaction status
status
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canBeginTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be started.
protected boolean

Returns:

true if the current state allows for a transaction to be committed
canCommitTransaction_impl
(Object
The current transaction status
status
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canCommitTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be committed.
protected boolean

Returns:

true if the current state allows for the SQL to be sent to the database
canIssueSQLToDatabase_impl
(Object
The current transaction status
status
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canIssueSQLToDatabase_impl.

INTERNAL: Return true if the status indicates that the SQL should be issued to the db.
protected boolean

Returns:

true if the current state dictates that the unit of work should be merged
canMergeUnitOfWork_impl
(Object
The current transaction status
status
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canMergeUnitOfWork_impl.

INTERNAL: Return true if the status indicates that the unit of work should be merged into the shared cache.
protected boolean

Returns:

true if the current state allows for a transaction to be rolled back
canRollbackTransaction_impl
(Object
The current transaction status
status
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canRollbackTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be rolled back.
protected void
public static TransactionManager
protected int
getIntStatus(Object status)

INTERNAL: Convenience method to return the int value of the transaction status.

protected Object

Returns:

The active transaction object or id, or null if no transaction is active
getTransaction_impl
()

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.getTransaction_impl.

INTERNAL: Return the active external transaction, or null if none is currently active for this thread.
protected Object

Returns:

A key for the passed in transaction, or null if no transaction specified
getTransactionKey_impl
(Object
The transaction to which the returned key applies (may be null)
transaction
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.getTransactionKey_impl.

INTERNAL: Return a key for the specified external transaction object.
public TransactionManager

Returns:

The JTA TransactionManager that is used to obtain transaction state information and control the active transaction.
getTransactionManager
()

PUBLIC: Return the transaction manager used to control the JTA transactions.

protected Object

Returns:

The current transaction status
getTransactionStatus_impl
()

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.getTransactionStatus_impl.

INTERNAL: Return the transaction status as an object.
public boolean
isRolledBack_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.isRolledBack_impl.

INTERNAL: Return true if the transaction is rolled back.
protected void
protected void
registerSynchronization_impl(AbstractSynchronizationListener
The synchronization listener created for this transaction
listener
,
Object
The active transaction for which notification is being requested
txn
)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.registerSynchronization_impl.

INTERNAL: Register the specified synchronization listener with the given active transaction.
protected void
public static void
setDefaultTransactionManager(TransactionManager defaultTransactionManager)

PUBLIC: Set the JTA transaction manager to be used.

public void
setTransactionManager(TransactionManager
A valid JTA TransactionManager that can be accessed by this controller to obtain transaction state information and control the active transaction.
mgr
)

PUBLIC: Set the transaction manager used to control the JTA transactions.

protected String
statusToString_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.statusToString_impl.

INTERNAL: Convert the status to a string for tracing.
Inherited from org.eclipse.persistence.transaction.AbstractTransactionController:
addUnitOfWorkbeginTransactionbindToCurrentTransactionclearSequencingListenerscommitTransactiongetActiveSequencingCallbackgetActiveUnitOfWorkgetExceptionHandlergetListenerFactorygetSessiongetTransactiongetTransactionKeygetTransactionStatusgetUnitsOfWorkhasActiveUnitOfWorkinitializeSequencingListenersisSequencingCallbackRequiredjndiLookuplogTxStateTracelogTxTracelookupActiveUnitOfWorklookupActiveUnitOfWorkmarkTransactionForRollbacknoTransactionOrRolledBackOrCommitednumSessionsRequiringSequencingCallbackregisterSynchronizationListenerremoveSequencingListenerremoveUnitOfWorkrollbackTransactionsetExceptionHandlersetListenerFactorysetSessionsetUnitsOfWork

Field Detail

codesback to summary
pack-priv static String[] codes

INTERNAL: Convert the status to a string for tracing.

defaultTransactionManagerback to summary
protected static TransactionManager defaultTransactionManager
transactionManagerback to summary
protected TransactionManager transactionManager

Constructor Detail

JTATransactionControllerback to summary
public JTATransactionController()

PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.

JTATransactionControllerback to summary
public JTATransactionController(TransactionManager transactionManager)

PUBLIC: Return a new controller for use with a JTA 1.0 compliant TransactionManager.

Method Detail

acquireTransactionManagerback to summary
protected TransactionManager acquireTransactionManager() throws Exception

INTERNAL: 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:TransactionManager

The TransactionManager for the transaction system

beginTransaction_implback to summary
protected void beginTransaction_impl() throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.beginTransaction_impl.

INTERNAL: Begin an external transaction.

Annotations
@Override
canBeginTransaction_implback to summary
protected boolean canBeginTransaction_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canBeginTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be started. This would normally mean that no transaction is currently active.

Parameters
status:Object

The current transaction status

Returns:boolean

true if the current state allows for a transaction to be started

Annotations
@Override
canCommitTransaction_implback to summary
protected boolean canCommitTransaction_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canCommitTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be committed. This would normally mean that a transaction is currently active.

Parameters
status:Object

The current transaction status

Returns:boolean

true if the current state allows for a transaction to be committed

Annotations
@Override
canIssueSQLToDatabase_implback to summary
protected boolean canIssueSQLToDatabase_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canIssueSQLToDatabase_impl.

INTERNAL: Return true if the status indicates that the SQL should be issued to the db. This would normally mean that a transaction was active.

Parameters
status:Object

The current transaction status

Returns:boolean

true if the current state allows for the SQL to be sent to the database

Annotations
@Override
canMergeUnitOfWork_implback to summary
protected boolean canMergeUnitOfWork_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canMergeUnitOfWork_impl.

INTERNAL: 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.

Parameters
status:Object

The current transaction status

Returns:boolean

true if the current state dictates that the unit of work should be merged

Annotations
@Override
canRollbackTransaction_implback to summary
protected boolean canRollbackTransaction_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.canRollbackTransaction_impl.

INTERNAL: Return true if the status indicates that a transaction can be rolled back. This would normally mean that a transaction is currently active.

Parameters
status:Object

The current transaction status

Returns:boolean

true if the current state allows for a transaction to be rolled back

Annotations
@Override
commitTransaction_implback to summary
protected void commitTransaction_impl() throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.commitTransaction_impl.

INTERNAL: Commit the external transaction.

Annotations
@Override
getDefaultTransactionManagerback to summary
public static TransactionManager getDefaultTransactionManager()
getIntStatusback to summary
protected int getIntStatus(Object status)

INTERNAL: Convenience method to return the int value of the transaction status. Assumes that the status object is an Integer.

getTransaction_implback to summary
protected Object getTransaction_impl() throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.getTransaction_impl.

INTERNAL: Return the active external transaction, or null if none is currently active for this thread.

Returns:Object

The active transaction object or id, or null if no transaction is active

Annotations
@Override
getTransactionKey_implback to summary
protected Object getTransactionKey_impl(Object transaction) throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.getTransactionKey_impl.

INTERNAL: 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).

Parameters
transaction:Object

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

Returns:Object

A key for the passed in transaction, or null if no transaction specified

Annotations
@Override
getTransactionManagerback to summary
public TransactionManager getTransactionManager()

PUBLIC: Return the transaction manager used to control the JTA transactions.

Returns:TransactionManager

The JTA TransactionManager that is used to obtain transaction state information and control the active transaction.

getTransactionStatus_implback to summary
protected Object getTransactionStatus_impl() throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.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 current transaction status

Annotations
@Override
isRolledBack_implback to summary
public boolean isRolledBack_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.isRolledBack_impl.

INTERNAL: Return true if the transaction is rolled back.

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

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.markTransactionForRollback_impl.

INTERNAL: Mark the external transaction for rollback.

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

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.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
rollbackTransaction_implback to summary
protected void rollbackTransaction_impl() throws Exception

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.rollbackTransaction_impl.

INTERNAL: Roll back the external transaction.

Annotations
@Override
setDefaultTransactionManagerback to summary
public static void setDefaultTransactionManager(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.

setTransactionManagerback to summary
public void setTransactionManager(TransactionManager mgr)

PUBLIC: Set the transaction manager used to control the JTA transactions.

Parameters
mgr:TransactionManager

A valid JTA TransactionManager that can be accessed by this controller to obtain transaction state information and control the active transaction.

statusToString_implback to summary
protected String statusToString_impl(Object status)

Implements abstract org.eclipse.persistence.transaction.AbstractTransactionController.statusToString_impl.

Doc from org.eclipse.persistence.transaction.AbstractTransactionController.statusToString_impl.

INTERNAL: Convert the status to a string for tracing.

Annotations
@Override