EJB.11.1 Overview


This section provides a brief overview of transactions and illustrates a number of transaction scenarios in EJB.

EJB.11.1.1 Transactions

Transactions are a proven technique for simplifying application programming. Transactions free the application programmer from dealing with the complex issues of failure recovery and multi- user programming. If the application programmer uses transactions, the programmer divides the application's work into units called transactions. The transactional system ensures that a unit of work either fully completes, or the work is fully rolled back. Furthermore, transactions make it possible for the programmer to design the application as if it ran in an environment that executes units of work serially .

Support for transactions is an essential component of the Enterprise JavaBeans architecture. The enterprise bean provider and the client application programmer are not exposed to the complexity of distributed transactions. The bean provider can choose between using programmatic transaction demarcation in the enterprise bean code (this style is called bean-managed transaction demarcation ) or declarative transaction demarcation performed automatically by the EJB container (this style is called container-managed transaction demarcation ).

With bean-managed transaction demarcation, the enterprise bean code demarcates transactions using the javax.transaction.UserTransaction interface. All resource manager [1] accesses between the UserTransaction.begin and UserTransaction.commit calls are part of a transaction.

[1] The terms resource and resource manager used in this chapter refer to the resources declared in the enterprise bean's deployment descriptor using the resource-ref element. These resources are considered to be "managed" by the container.

With container-managed transaction demarcation, the container demarcates transactions per instructions provided by the application assembler in the deployment descriptor. These instructions, called transaction attributes , tell the container whether it should include the work performed by an enterprise bean method in a client's transaction, run the enterprise bean method in a new transaction started by the container, or run the method with "no transaction" (refer to Section EJB.11.6.3 for the description of the "no transaction" case).

Regardless of whether an enterprise bean uses bean-managed or container-managed transaction demarcation, the burden of implementing transaction management is on the EJB container and server provider. The EJB container and server implement the necessary low-level transaction protocols, such as the two-phase commit protocol between a transaction manager and a database system, transaction context propagation, and distributed two-phase commit.

EJB.11.1.2 Transaction Model

The Enterprise JavaBeans architecture supports flat transactions. A flat transaction cannot have any child (nested) transactions.

Note

The decision not to support nested transactions allows vendors of existing transaction processing and database management systems to incorporate support for Enterprise JavaBeans. If these vendors provide support for nested transactions in the future, Enterprise JavaBeans may be enhanced to take advantage of nested transactions.


EJB.11.1.3 Relationship to JTA and JTS

The Java Transaction API (JTA) [EJB.5] is a specification of the interfaces between a transaction manager and the other parties involved in a distributed transaction processing system: the application programs, the resource managers, and the application server.

The Java Transaction Service (JTS) [EJB.6] API is a Java programming language binding of the CORBA Object Transaction Service (OTS) 1.1 specification. JTS provides transaction interoperability using the standard IIOP protocol for transaction propagation between servers. The JTS API is intended for vendors who implement transaction processing infrastructure for enterprise middleware. For example, an EJB server vendor may use a JTS implementation as the underlying transaction manager.

The EJB architecture does not require the EJB container to support the JTS interfaces. The EJB architecture requires that the EJB container support the javax.transaction.UserTransaction interface defined in JTA, but it does not require the support for the JTA resource and application server interfaces.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net