Network Deployment (Distributed operating systems), v8.0 > End-to-end paths > ActivitySessions > The ActivitySession service
ActivitySession samples
WAS provides some ActivitySession samples.
MasterMind sample
This sample is based on the game MasterMind. It consists of the following components:
- A servlet, configured with the ActivitySession control kind attribute set to Container, that accesses a stateful session bean.
- A stateful session bean, configured with an activation policy of ActivitySession containing transient state data.
The servlet begins an HttpSession at the start of each new game, and ends it at the end of each game; therefore an ActivitySession lasts for the duration of each game. The ActivitySession activation policy stops the bean from being passivated and therefore the transient data remains in memory. This sample demonstrates the association between HttpSession and ActivationSession in the web container, and an ActivitySession-scoped activation policy.
Enterprise application client container and a CMP entity bean backed by a one-phase commit data source
In this sample, the entity bean is configured with the following properties:
- TX_NOT_SUPPORTED
- An ActivitySession container managed policy of REQUIRES
- An LTC boundary of ActivitySession
- An LTC Resolution Control of ContainerAtBoundary
The client accesses the UserActivitySession, begins an ActivitySession, updates two instances of the bean, then ends the ActivitySession. It does this twice using EndModeReset then EndModeCheckpoint. This sample demonstrates the following functionality:
- Client access to the UserActivitySession interface
- Multiple resource manager local transactions (RMLTs) being scoped to the ActivitySession and taking their completion direction automatically from that of the ActivitySession
The entity bean also holds a transient variable that each method call increments (gets and sets for the persistent data). This value is checked before the end of the ActivitySession to show that the same bean instance is used. The client checks for the correct results.
An enterprise application client container and two session beans with different ActivitySession types
This sample consists of an enterprise application client container and the following session beans:
- SLB1, a stateless session bean configured with an ActivitySession Type of Bean.
- SFB2, a stateful session bean configured with ActivitySession Type of Requires, an LTC boundary of ActivitySession, LTC Resolution Contol of APPLICATION, and an LTC Unresolved Action of ROLLBACK.
Both beans are configured with TX_NOTSUPPORTED.
This sample uses the following steps:
- The client starts SLB1
- SLB1 accesses the UserActivitySession interface, begins an ActivitySession, then calls a method on SFB2
- SFB2 accesses the UserActivitySession interface, begins an ActivitySession, calls a method on SFB2
- SFB2 gets a connection (setAutoCommit false) then uses JDBC to update a single-phase data source.
- Optionally, SLB1 calls a separate method on SFB2 to finish the work, either committing or rolling back the RMLT.
- SLB1 then ends the ActivitySession with an EndModeCheckpoint.
This sample demonstrates the following functionality:
- The ActivitySession completion direction is unconnected to the direction of the RMLTs, although the containment of the RMLTs is bound to the ActivitySession.
- The container using the unresolved action when an RMLT is not completed.
- A bean-managed ActivitySessions bean using the UserActivitySession interface.
The sample checks for correct results and reports them back to the client.
ActivitySession service application programming interfaces
Use the ActivitySession service