Clients can begin, commit, and roll back ACID transactions1 using an implementation of the Java™ Transaction Service (JTS) or the CORBA Object Transaction Service (OTS). These transactions are analogous to CICS® distributed units of work. We use the term OTS transaction to differentiate these transactions from CICS transaction definitions (the ones with 4-character transaction identifiers) and CICS transaction instances (which are sometimes loosely called “tasks”).
When a client calls an enterprise bean in the scope of an OTS transaction, information about the transaction flows to the EJB server in an IIOP “service context”, which is like an extra (hidden) parameter on the method request. The EJB server uses this information if it needs to participate in the transaction. Whether the method of an enterprise bean needs to run under a client's OTS transaction (if there is one) is determined by the setting of the transaction attribute specified in the bean's deployment descriptor. The method may run under the client's OTS transaction, under a separate OTS transaction which is created for the duration of the method, or under no OTS transaction.
Entity beans must use container–managed OTS transactions. All transaction functions are performed implicitly by the EJB container and server. There are no transaction demarcation statements within the bean code.
Session beans can use either container-managed OTS transactions or bean–managed OTS transactions. A session bean that uses bean–managed transactions uses methods of the javax.transaction.UserTransaction interface to demarcate transactions. A stateful session bean that manages its own transactions can begin an OTS transaction in one method and commit or roll it back in a subsequent method. A stateless session bean that manages its own transactions and begins an OTS transaction must commit (or roll back) the transaction in the same method.
At runtime, the EJB container implements transaction services according to the setting of the transaction attribute specified in the bean's deployment descriptor. The possible settings of the transaction attribute are:
The setting of a method's transaction attribute determines whether or not the CICS task under which the method executes makes its unit of work part of a wider, distributed OTS transaction.
A single CICS task cannot contain more than one enterprise bean, because CICS treats an execution of an enterprise bean method as the start of a new task. You can create an application that includes more than one enterprise bean, but the application will not operate as a single CICS task.