Extended JTA support provides application programming interfaces additional to the UserTransaction interface that is defined in the JTA as part of the J2EE specification. Specifically, the API extensions provide the following functionality:
The global id is based on the tid in CosTransactions::PropagationContext: and the local id identifies the transaction uniquely within the local JVM.
This can be used by advanced applications to flush updates before transaction completion and clear up state after transaction completion. J2EE (and related) specifications position this function generally as the domain of the J2EE containers.
The
exception is for CMT session beans, for which the EJB specification defines
the SessionSynchronization interface. WebSphere provides this WebSphere Application
Server Enterprise functionality in recognition that more advanced applications
can profit from the ability to receive such notifications.
An application uses a JNDI lookup of java:comp/websphere/ExtendedJTATransaction to get an ExtendedJTATransaction object, which it then uses as follows:
ExtendedJTATransaction exJTA = (ExtendedJTATransaction)ctx.lookup(" java:comp/websphere/ExtendedJTATransaction"); SynchronizationCallback sync = new SynchronizationCallback(); exJTA.registerSynchronizationCallback(sync);
The ExtendedJTATransaction object supports the registration of one or more application-provided SynchronizationCallbacks. Each registered callback is called at the end of every transaction that runs on the application server (whether the transaction is started locally or imported).
The following information provides an overview of the interfaces provided by the Extended JTA support. For more detailed information, see the Javadoc provided with WebSphere Application Server EnterpriseWBI Server Foundation.
SynchronizationCallback interface
An object implementing this interface is enlisted once through the ExtendedJTATransaction interface, and receives notification of the completion of each subsequent transaction mediated by the transaction manager in the local JVM.
Although an object implementing this interface can run in a J2EE server, there is no specific J2EE component active when this object is called. So, the object has limited direct access to any J2EE resources. Specifically, it has no access to the java: namespace or to any container-mediated resource. Such an object can cache a reference to a J2EE component (for example, a stateless session bean) that it delegates to. The object would then have all the normal access to J2EE resources and could be used, for example, to acquire a JDBC connection and flush updates to a database during beforeCompletion.
ExtendedJTATransaction interface
A WebSphere programming model extension to the J2EE JTA support. An object implementing this interface is bound, by WebSphere J2EE containers that support this interface, at java:comp/websphere/ExtendedJTATransaction. Access to this object, when called from an EJB container, is not restricted to bean-managed transactions.