Extended JTA support
Extended Java Transaction API (JTA) support provides APIs additional to the UserTransaction interface that is defined in the JTA as part of the J2EE specification. The API extensions provide the following functionality:
- Access to global and local transaction identifiers associated with the thread.
The global identifier is based on the transaction identifier in the CosTransactions::PropagationContext: object and the local identifier identifies the transaction uniquely in the local JVM.
- A transaction synchronization callback that any J2EE component can use to register an interest in transaction completion.
Advanced applications can use this callback 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.
An application uses a Java Naming and Directory Interface (JNDI) lookup of java:comp/websphere/ExtendedJTATransaction to get an ExtendedJTATransaction object, which the application uses as shown in the following example::
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 SynchronizationCallback objects. Depending on how the callback is registered, each registered callback is called at one of the following points:
- At the end of every transaction that runs on the appserver, whether the transaction is started locally, or imported.
- At the end of the transaction for which the callback was registered
The following information is an overview of the interfaces that the Extended JTA support provides. For more detailed information, see the generated API documentation.
SynchronizationCallback interface
An object implementing this interface is enlisted once through the ExtendedJTATransaction interface, and receives notification of transaction completion.
Although an object implementing this interface can run on 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, the object 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. For example, you could use it to acquire a Java Database Connectivity (JDBC) connection and flush updates to a database during the beforeCompletion method.
ExtendedJTATransaction interface
This interface is a WebSphere programming model extension to the J2EE JTA support. An object implementing this interface is bound, by J2EE containers in WebSphere Application Server that support this interface, at java:comp/websphere/ExtendedJTATransaction. Access to this object, when called from an EJB container, is not restricted to component-managed transactions.
Related concepts
Global transactions
Transaction support in WAS
Related tasks
Use the transaction service
Related information
Reference: Generated API documentation