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.

 

Overview

One can configure the deployment attributes of an application by using an assembly tool such as the Application Server Toolkit (AST) or Rational Web Developer.

This topic describes the use of the Application Server Toolkit (AST) 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). This task description assumes that you have an EAR file, which contains an application enterprise bean that can be deployed in WebSphere Application Server. For more details about assembling applications, see assembling applications. 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

  1. Start the assembly tool.

  2. Create or edit the application EAR file.

    Note: Ensure that you set the target server as WAS v6.

    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:

    1. Click File-> Import-> EAR file

    2. Click Next, then select the EAR file.

    3. In the Target server field, select WebSphere Application Server v6.0

    4. Click Finish

  3. 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.

  4. In the property pane, select the Beans tab.

  5. Select the bean that you want to change.

  6. 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.

  7. 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.

  8. For entity beans, or session beans, set the ActivitySessions properties for each EJB method.

    1. In the property pane, select the ActivitySession tab.

    2. 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.

    3. Click Next.

    4. Select the methods to which the ActivitySession kind policy is to be applied.

    5. 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 inSetting transactional attributes in the deployment descriptor. For more detail about the relationship between these two properties, see Combining transaction and ActivitySession container policies.

  9. Save your changes to the deployment descriptor.

    1. Close the Deployment Descriptor Editor.

    2. When prompted, click Yes to indicate that you want to save changes to the deployment descriptor.

  10. Verify the archive files.

  11. From the popup menu of the project, click Deploy to generate EJB deployment code.

  12. Optional: Test your completed module on a WAS installation. Right-click a module, click Run on Server, and follow the instructions in the displayed wizard. Note that Run on Server works on the Windows, Linux/Intel, and AIX operating systems only; one cannot deploy remotely from the Application Server Toolkit (AST) or Rational Web Developer to a WAS installation on a UNIX operating system such as Solaris. Important

    Note: Use Run On Server for unit testing only. The Application Server Toolkit (AST) or Rational Web Developer 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 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 managing applications.


 

See Also


The ActivitySession service

 

See Also


Combining transaction and ActivitySession container policies