The Java Transaction API (JTA) extensions notify an application of the completion of every transaction that runs on a server. Applications receive notification of each transaction beforeCompletion and afterCompletion events, by registering an implementation of the SynchronizationCallback interface. This sample comprises a servlet that registers for synchronization callbacks when it is initialized. The servlet displays a table detailing every completed transaction on the server since registration. For the user's convenience, an option is provided to run a new transaction that can either be commited or rolled back.
COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample code is written. Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS TO THE SAMPLE SOURCE CODE.
The following key phrases are associated with this sample: ExtendedJTATransaction, "JTA Extensions", beforeCompletion, afterCompletion, SynchronizationCallback
This interface provides a WebSphere programming model extension to the Java EE JTA support. An object implementing this interface will be bound, by WebSphere product Java EE containers that support this interface, at java:comp/websphere/ExtendedJTATransaction.
The main features to note in the sample are the lookup of the ExtendedJTATransaction object and the registration of the SynchronizationCallback, both of which are performed in the init method of the TransactionTracker servlet.
The beforeCompletion and afterCompletion methods are the methods that are driven by the ExtendedJTATransaction functionality whenever a transaction undergoes completion, following the registration of a callback.
For more information, see the API documentation in the WebSphere Application Server Information Center.
samples_root/src | Contains the sample source code for the JTA Extensions Sample. |
samples_root/installableApps | Contains the EAR file comprising the built JTA Extensions sample application: JTAExtensionsSample.ear. This directory is created when the sample is built. |
samples_root/javadoc | Contains the API documentation generated when the sample is built. |
samples_root/scripts | Contains the script files used to build the sample. |
The buildsamples.bat and the buildsamples scripts in the samples_root/scripts directory run the Ant build utility. Ant reads the build.xml files, which describe how to build the sample. Refer to the Ant web site for additional documentation on Ant.
During the build process, only class files that have changes are rebuilt. The remaining class files are repackaged into the new Enterprise Archive (EAR) file.
On Windows operating systems:
wsadmin -conntype none -lang jython -c "AdminApp.install('JTAExtensionsSample.ear')"
wsadmin.sh -conntype none -lang jython -c "AdminApp.install('JTAExtensionsSample.ear')"
wsadmin.sh -conntype none -lang jython -c "AdminApp.install('JTAExtensionsSample.ear)"
wsadmin -conntype none -lang jython -c "AdminApp.install('JTAExtensionsSample.ear')"
http://<hostname>:<port>/JTAExtensionsSample/TransactionsTracker/TransactionsTracker
Where <hostname> and <port> are the hostname and port number of your application server.
On Windows operating systems:
wsadmin -conntype none -lang jython -c "AdminApp.uninstall('JTA Extensions Sample')"
wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('JTA Extensions Sample')"
wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('JTA Extensions Sample')"
wsadmin -conntype none -lang jython -c "AdminApp.uninstall('JTA Extensions Sample')"
The following illustration shows the correctly running sample: