The ActivitySession service is implemented as a high-level service on top of the implementation of the Java 2 Platform, Enterprise Edition (J2EE) 1.4 Activity Service. It provides a unit-of-work scope within which unrecoverable or non-two-phase resources can be managed, and does this in a way that is both distributed and cooperative with respect to transactions. Use this collection of sample applications to explore the ActivitySession service.
Less than one hour
To use the samples, download ActivitySession Service application sample files from a product download site. Complete the following steps:
A servlet provides the user interface for the MasterMind game. The game uses an HTTP session to control the ActivitySession life-cycle, and communicates with an enterprise bean, which holds the state and provides the logic for the game. The aim of the game is to guess the four-element code that is generated at the start. On each guess, clues are given to the identity of the target code by how many elements in the guess are present in the target and how many of these elements are correctly placed.
This sample consists of a client, which begins and ends the ActivitySessions service, updating an entity bean. The sample demonstrates client access to the UserActivitySession interface, container-managed ActivitySessions service and container resolution of resource-managed local transactions. These transactions start within the enterprise beans that have a Local Transaction Containment (LTC) boundary of ActivitySession. The client verifies that updates to bean instances are committed when the ActivitySession service is completed with the EndModeCheckpoint and rolled back when the EndModeReset is used.
This sample consists of a client that invokes a method on a stateless session bean. This session bean uses bean-managed activity sessions, beginning and ending the ActivitySessions with the UserActivitySession interface. During these activity sessions, a stateful session bean is accessed. This stateful session bean, which uses the container-managed ActivitySession service, an LTC boundary of ActivitySession, and an LTC resolution control of Application, is called several times to update data in a database. Sometimes the stateful session bean is instructed to complete the resource manager local transactions (RMLTs), either to commit them or roll them back. Sometimes the RMLTs are left incomplete. The stateless session bean then completes the ActivitySession service and reports back to the client whether the results are consistent with the expected behavior.