Use this task to set the ActivitySession deployment attributes
for an enterprise bean to enable the bean to participate in an ActivitySession
context and support ActivitySession-based operations.
Before you begin
This task description assumes that you have an Enterprise
Archive (EAR) file that contains an application enterprise bean that
can be deployed in WebSphere Application Server. For more details
about assembling applications, see
assembling applications.
About this task
You configure the deployment attributes of an application
by using an assembly
tool. This topic describes the use of the Application Server
Toolkit to configure the ActivitySession deployment attributes. These
attributes are in addition to other deployment attributes, like Load
at (which specifies when the bean loads its state from the database).
For more detail about the fields in the assembly tool, and for associated
task help, see the help information provided with the toolkit.
To
set the ActivitySession deployment attributes for an enterprise bean,
complete the following steps:
Procedure
- Start the assembly tool. For more information
about starting the Application Server Toolkit, refer to the Application
Server Toolkit information in the navigation pane of this information
center.
- Create or edit the application EAR file.
Note: Ensure
that you set the target server as WebSphere Application Server Version
6.1.
For example, to change attributes of an existing application,
use the import wizard to import the EAR file into the assembly tool.
To start the import wizard:
- Click File-> Import-> EAR file
- Click Next, then select the EAR
file.
- In the Target server field, select WebSphere
Application Server v6.1
- Click Finish
- In the J2EE Hierarchy view of the J2EE perspective, right-click
the EJB module for the enterprise bean instance, then click Open
With > Deployment Descriptor Editor. A property
dialog notebook for the enterprise bean instance is displayed in the
property pane.
- In the property pane, select the Beans tab.
- Select the bean that you want to change.
- In the WebSphere Extensions section, under Bean Cache,
set the Activate at attribute to ActivitySession:
An enterprise bean with this activation policy is activated
and passivated as follows:
- On an ActivitySession boundary, if an ActivitySession context
is present on activation.
- On a transaction boundary, if a transaction context, but no ActivitySession
context, is present on activation.
- Otherwise on an invocation boundary.
- In the Local Transactions group box, set the Boundary attribute
to ActivitySession: When this setting is used, the
local transaction must be resolved within the scope of any ActivitySession
in which it was started or, if no ActivitySession context is present,
within the same bean method in which it was started.
A
setting of ActivitySession does not apply to any EJB home methods,
for example, create or finder methods. EJB home methods cannot participate
in an ActivitySession because this situation might cause deadlocks.
- For entity beans, or session beans, set the ActivitySession
properties for each EJB method.
- In the property pane, select the ActivitySession tab.
- In the Configure ActivitySession policies field,
click Add or Edit to set the ActivitySession kind attribute
for methods of the enterprise bean. This specifies how the container
must manage the ActivitySession boundaries when delegating a method
invocation to an enterprise bean's business method:
- Never
- The container invokes bean methods without an ActivitySession
context.
- If the client invokes a bean method from within an ActivitySession
context, the container throws an InvalidActivityException exception,
which is a javax.rmi.RemoteException.
- If the client invokes a bean method from outside an ActivitySession
context, the container behaves in the same way as if the Not Supported value
was set. The client must call the method without an ActivitySession
context.
- Mandatory
- The container always invokes the bean method within the ActivitySession
context associated with the client. If the client attempts to invoke
the bean method without an ActivitySession context, the container
throws an ActivityRequiredException exception to the client. The ActivitySession
context is passed to any EJB object or resource accessed by an enterprise
bean method.
The ActivityRequiredException exception is javax.rmi.RemoteException.
- Requires new
- The container always invokes the bean method within a new ActivitySession
context, regardless of whether the client invokes the method within
or outside an ActivitySession context. The new ActivitySession context
is passed to any enterprise bean objects or resources that are used
by this bean method.
Any received ActivitySession context is suspended
for the duration of the method and resumed after the method ends.
The container starts a new ActivitySession before method dispatch
and completes it after the method ends.
- Required
- The container invokes the bean method within an ActivitySession
context. If a client invokes a bean method from within an ActivitySession
context, the container invokes the bean method within the client ActivitySession
context. If a client invokes a bean method outside an ActivitySession
context, the container creates a new ActivitySession context and invokes
the bean method from within that context. The ActivitySession context
is passed to any enterprise bean objects or resources that are used
by this bean method.
- Not supported
- The container invokes bean methods without an ActivitySession
context. If a client invokes a bean method from within an ActivitySession
context, the container suspends the association between the ActivitySession
and the current thread before invoking the method on the enterprise
bean instance. The container then resumes the suspended association
when the method invocation returns. The suspended ActivitySession
context is not passed to any enterprise bean objects or resources
that are used by this bean method.
- Supports
- If the client invokes the bean method within an ActivitySession,
the container invokes the bean method within an ActivitySession context.
If the client invokes the bean method without a ActivitySession context,
the container invokes the bean method without an ActivitySession context.
The ActivitySession context is passed to any enterprise bean objects
or resources that are used by this bean method.
- Click Next.
- Select the methods to which the ActivitySession kind
policy is to be applied.
- Click Finish.
How the container manages the ActivitySession boundaries
when delegating a method invocation depends on both the ActivitySession
kind set here, and the Container transaction type as described
in Configuring transactional deployment attributes. For more detail about the relationship between
these two properties, see ActivitySession and transaction container policies in combination.
- Save your changes to the deployment descriptor.
- Close the Deployment Descriptor Editor.
- When prompted, click Yes to indicate
that you want to save changes to the deployment descriptor.
- Verify the archive files. For more information
about verifying files using the Application Server Toolkit, refer
to the Application Server Toolkit information in the navigation pane
of this information center.
- From the popup menu of the project, click Deploy to
generate EJB deployment code.
- Optional: Test your completed module on a WebSphere
Application Server installation. Right-click a module, click Run
on Server, and follow the instructions in the displayed wizard.
Important: Use Run On Server for unit testing
only. The assembly tool controls the WebSphere Application Server
installation and, when an application is published remotely, the assembly
tool overwrites the server configuration file for that server. Do
not use on production servers.
What to do next
After assembling your application, use a systems management
tool to deploy the EAR file onto the application server that is to
run the application; for example, using the administrative console
as described in
Deploying and administering J2EE applications.