Set EJB module ActivitySession deployment attributes
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.
This task description assumes that we have an EAR file, which contains an application enterprise bean that can be deployed in WebSphere Application Server. For more details, see the topic about assembling applications.
You configure the deployment attributes of an application by using an assembly tool. This topic describes the use of Rational Application Developer to configure the ActivitySession deployment attributes. These attributes are in addition to other deployment attributes, for example, "Load at", which specifies when the bean loads its state from the database. For details about the fields in the assembly tool, and for associated task help, refer to the Rational Application Developer information.
To set the ActivitySession deployment attributes for an enterprise bean...
- Start the assembly tool. For more information, refer to the Rational Application Developer information.
- Create or edit the application EAR file.
Ensure set the target server as WAS v7.
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 v7.0.
- Click Finish.
- In the Project Explorer view of the Java EE 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 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 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 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 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 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 the topic about configuring transactional deployment attributes. For more detail about the relationship between these two properties, see the topic about ActivitySession and transaction container policies in combination.
- Save the changes to the deployment descriptor.
- Close the Deployment Descriptor Editor.
- When prompted, click Yes to save changes to the deployment descriptor.
- Verify the archive files. For more information about verifying files using Rational Application Developer, refer to the Rational Application Developer information.
- From the popup menu of the project, click Deploy to generate EJB deployment code.
- Optional: Test the completed module on a WAS 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 WAS installation and, when an application is published remotely, the assembly tool overwrites the server configuration file for that server. Do not use the Run On Server option on production servers.
What to do next
After assembling the application, use a systems management tool to deploy the EAR file onto the application server that is to run the application. For example, to use the administrative console, see the topic about deploying and administering enterprise applications.
Related concepts
The ActivitySession service Development and assembly tools
Related tasks
Assembling applications Configure transactional deployment attributes Deploy
ActivitySession and transaction container policies in combination
Related information: