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.
The following table describes the transaction manager APIs supported by Application Server.
Table 3-16 Transaction manager APIs supported by Application Server
Interface | Method | Availability |
---|---|---|
javax.transaction.TransactionManager | begin | Y |
commit | Y | |
getStatus | Y | |
getTransaction | Y | |
resume | Y | |
rollback | Y | |
setRollbackOnly | Y | |
setTransactionTimeout | Y | |
suspend | Y | |
javax.transaction.Transaction | commit | Y |
delistResource | -- | |
enlistResource | -- | |
getStatus | Y | |
registerSynchronization | Y | |
rollback | Y | |
setRollbackOnly | Y |
Legend:
Y: Available
--: Not available
Note: If you try to use an unavailable method, javax.transaction.SystemException is thrown.
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.