CONTENTS | PREV | NEXT | INDEX Designing Enterprise Applications
with the J2EETM Platform, Second Edition



8.3 J2EE Transaction Technologies

The Java Transaction API and the J2EE platform specifications define the overall transactional behavior in the J2EE architecture. The JTA specification defines the contracts between applications, application servers, resource managers, and transaction manager. The J2EE platform specification defines the requirements for the J2EE transaction management and runtime environment.

8.3.0.0.1 Java Transaction API (JTA)

JTA specifies standard Java interfaces between a transaction manager and the distributed transaction participants it coordinates: applications, application servers, and resource managers. JTA defines interfaces that let applications, application servers, and resource managers participate in transactions regardless of their implementations.

A JTA transaction is a transaction managed and coordinated by the J2EE platform. A J2EE product is required to support JTA transactions as defined in the J2EE specification. A JTA transaction can span multiple components and enterprise information systems. A transaction is propagated automatically between components and to enterprise information systems accessed by components within the transaction. For example, a JTA transaction may comprise a servlet or JSP page accessing multiple enterprise beans, some of which access one or more resource managers.

JTA transactions begin either explicitly in code or implicitly by an EJB server. A component can explicitly begin a JTA transaction using interface javax.transaction.UserTransaction. An EJB container implicitly begins a JTA transaction when a client accesses an enterprise bean that uses container-managed transaction demarcation.

Most J2EE application component providers use only the JTA UserTransaction interface, and then only when choosing to use bean-managed transactions rather than container-managed transactions. An application component provider uses the JTA UserTransaction interface to demarcate JTA transaction boundaries in components. The JTA TransactionManager and XAResource interfaces are low-level APIs between a J2EE server and enterprise information system resource managers and are not intended to be used by applications.

The main benefit of using JTA transactions is the ability to combine multiple components and enterprise information system accesses into one single transaction with little programming effort. The J2EE platform propagates transactions between multiple components and enterprise information systems with no additional programming effort. Enterprise beans using container-managed transaction demarcation (See Section 8.6.2 on page 264) do not need to begin or commit transactions programmatically, because the EJB container automatically handles the demarcation.

JTA transactions are recommended when accessing EIS resources; see Section 8.7.3 on page 269.



CONTENTS | PREV | NEXT | INDEX
Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved.