Operating Systems: i5/OS
Personalize the table of contents and search results
Defining container transactions for EJB modules
Container transaction properties specify how an Enterprise JavaBeans
(EJB) container is to manage transaction scopes for the enterprise bean's
method invocations. A transaction attribute is mapped to one or more methods. Some
container transaction settings are not available for all enterprise beans.
Also, some methods are not available for particular transaction settings and
beans. These rules have been implemented in the Add Container Transaction
wizard based on the EJB 1.1 and EJB 2.x specifications.
Overview
To add a container transaction to an enterprise bean:
Procedure
- In the Project Explorer view of the J2EE perspective, right-click
the Deployment Descriptor for your EJB project and select Open
With > Deployment Descriptor Editor to
open the deployment descriptor editor.
- On the Assembly page of the editor, click Add in
the Container Transactions section.
- Select one or more enterprise beans from the list of beans found.
- Select a container transaction type from the following choices:
- NotSupported - Directs the container to invoke
bean methods without a transaction context. If a client calls a bean method
from within a transaction context, the container suspends the association
between the transaction 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 transaction
context is not passed to any enterprise bean objects or resources that are
used by this bean method.
- Supports - Directs the container to invoke
the bean method within a transaction context if the client calls the bean
method within a transaction . If the client calls the bean method without
a transaction context, the container calls the bean method without a transaction
context. The transaction context is passed to any enterprise bean objects
or resources that are used by this bean method.
- Required - Directs the container to invoke
the bean method within a transaction context. If a client calls a bean method
from within a transaction context, the container calls the bean method within
the client transaction context. If a client calls a bean method outside a
transaction context, the container creates a new transaction context and calls
the bean method from within that context. The transaction context is passed
to any enterprise bean objects or resources that are used by this bean method.
- RequiresNew - Directs the container to always
invoke the bean method within a new transaction context, regardless of whether
the client calls the method within or outside a transaction context. The transaction
context is passed to any enterprise bean objects or resources that are used
by this bean method.
- Mandatory - Directs the container to always
invoke the bean method within the transaction context associated with the
client. If the client attempts to invoke the bean method without a transaction
context, the container throws the javax.jts.TransactiononRequiredException
exception to the client. The transaction context is passed to any EJB object
or resource accessed by an enterprise bean method. EJB clients that access
these entity beans must do so within an existing transaction . For other enterprise
beans, the enterprise bean or bean method must implement the Bean Managed
value or use the Required or Requires New value. For non-enterprise bean EJB
clients, the client must invoke a transaction by using the javax.transaction.UserTransaction
interface.
- Never - Directs the container to invoke bean
methods without a transaction context. If the client calls a bean method from
within a transaction context, the container throws the java.rmi.RemoteException
exception. If the client calls a bean method from outside a transaction context,
the container behaves in the same way as if the Not Supported transaction
attribute was set. The client must call the method without a transaction context
- Select one or more methods elements from the list.
- Click Finish.
Results
The container transaction is added and displayed in the Container
Transactions section, where the container transactions are listed by container
transaction type.
What to do next
After you define container transactions, you can use the deployment
descriptor editor to work with them. Information about the editor can be found
in the WebSphere Application Server Express documentation.
- To edit a container transaction, select it from the Container Transactions
list and click Edit.
- To delete a container transaction, select from the list and click Remove.
- To take multiple container transactions that are the same container transaction
type and combine them into a single container transaction definition, click Combine.
}
EJB containers
Related tasks
Assembling EJB modules
|