ActivitySessions service

 

+

Search Tips   |   Advanced Search

 

The ActivitySession service provides a unit-of-work scope within which non-recoverable or non-two-phase resources can be managed, and in a way that is both distributed and cooperative with respect to transactions.

Enterprise beans now have ActivitySession attributes that you can specify on a per-method basis as part of deployment. You can use the Assembly Toolkit provided with the Application Server Toolkit to specify this attribute. These attributes follow the model established by the transaction attributes defined in the EJB specification with ActivitySessions being either bean managed, or container managed. The EJB container also supports activation and passivation policies scoped to ActivitySession service and supports local transactions scoped to ActivitySession attributes, rather than be restricted to method invocation boundaries.

Activity sessions can also be used in the Web container and can be related to Http sessions. Web Applications can be deployed with the following ActivitySession control values:

Application The Web application is responsible for starting and ending the Activity Sessions service and for moving ActivitySession context to and from the thread.
Container The Web application has no access to the UserActivitySession interface. Every Http session created by the Web application has an ActivitySession service implicitly created and associated it.
None The Web application does not use the ActivitySessions service.

 

Http session association (MasterMind)

Run    |    Technotes    |    Javadoc    |    Build with Ant

A servlet provides the user interface for a game called MasterMind. The game uses an Http session to control the ActivitySession lifecycle, and talks to 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.

 

Container-managed ActivitySessions

Configure and run    |    Technotes    |    Javadoc    |    Build with Ant

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.

 

Bean-managed ActivitySessions

Configure and run    |    Technotes    |    Javadoc    |    Build with Ant

This Sample consists of a client that invokes a method on a stateless session bean. This session bean uses bean-managed activity sessions, begining and ending the ActivitySessions what 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.