This topic describes the ActivitySession samples provided with
WebSphere Application Server.
- MasterMind sample
-
This sample is based on the game MasterMind. It consists of the following
components:
- A servlet, configured with ActivitySession contol 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 is to demonstrate HttpSession/ActivationSession association in the web
container, and an ActivitySession-scoped activation policy.
- J2EE client container application and a CMP entity bean backed by a one-phase
commit datasource
-
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 RMLTs being scoped to the ActivitySession and automatically taking
their completion direction from that of the ActivitySession
The entity bean also holds a transient variable incremented by
each method call (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.
- A J2EE client container application and two session beans with different
ActivitySession types
-
This sample consists of a J2EE client container application 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
performs 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 datasource.
- SLB1 then optionally calls a seperate 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 RMLTs containment 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.