3.4.6 Obtaining the transaction manager

The transaction manager (javax.transaction.TransactionManager or javax.transaction.Transaction) provides APIs for managing transactions. To use the framework that uses the transaction manager APIs, you can use the JNDI to obtain the transaction manager. To obtain the transaction manager, look up with the name java:comp/TransactionManager.

This subsection describes the transaction manager APIs supported by Application Server, and the notes on using Synchronization.

Organization of this subsection
(1) Supported APIs
(2) Notes on using the transaction manager
(3) Notes on using Synchronization

(1) Supported APIs

The following table describes the transaction manager APIs supported by Application Server.

Table 3-16 Transaction manager APIs supported by Application Server

InterfaceMethodAvailability
javax.transaction.TransactionManagerbeginY
commitY
getStatusY
getTransactionY
resumeY
rollbackY
setRollbackOnlyY
setTransactionTimeoutY
suspendY
javax.transaction.TransactioncommitY
delistResource--
enlistResource--
getStatusY
registerSynchronizationY
rollbackY
setRollbackOnlyY

Legend:

Y: Available

--: Not available

Note: If you try to use an unavailable method, javax.transaction.SystemException is thrown.


(2) Notes on using the transaction manager

(3) Notes on using Synchronization

You cannot use the services provided by the J2EE server with the beforeCompletion method and afterCompletion method of Synchronization (javax.transaction.Synchronization) registered using the registerSynchronization method of the transaction (javax.transaction.Transaction). The examples of services that are not available are as follows:

From among these services, when resource access is performed, some of the transactions managed by the transaction manager are not managed when the resources are accessed, so a mismatch might occur. To access the resources, specify settings in any framework so that the framework controls the direct transactions for the resources.

Because the above precautions need to be taken, we do not recommend the use of Synchronization in the user programs. If you want to use the transaction conclusion timing from the user program, use javax.ejb.SessionSynchronization of the EJB.