| CONTENTS | PREV | NEXT | INDEX | J2EE BluePrints |
Support for transactions is an essential element of the J2EE architecture. The J2EE platform supports both programmatic and declarative transaction demarcation. The component provider can use the Java Transaction API to programmatically demarcate transaction boundaries in the component code. Declarative transaction demarcation is supported in enterprise beans, where transactions are started and completed automatically by the enterprise bean's container. In both cases, the burden of implementing transaction management is on the J2EE platform. The J2EE server implements the necessary low-level transaction protocols, such as interactions between transaction manager and JDBC database systems, transaction context propagation, and optionally distributed two-phase commit. Currently, the J2EE platform only supports flat transactions. A flat transaction cannot have any child (nested) transactions.
The J2EE platform supports a transactional application that is comprised of a combination of servlets and/or JSP pages accessing multiple enterprise beans within a single transaction. Each component may acquire one or more connections to access one or more shared resource managers. Currently, the J2EE platform is only required to support access to a single JDBC database within a transaction (multiple connections to the same database are allowed). It is not required to support access to multiple JDBC databases within a single transaction. It is also not required to support access to other types of enterprise information systems such as enterprise resource planning systems. However, some products might choose to provide these extra transactional capabilities. For example, the J2EE SDK supports access to multiple JDBC databases in one transaction using the two-phase commit protocol.
It is important for developers to understand and distinguish which transaction capabilities are required and which are optional in a J2EE product. To write a truly portable application, developers should only use features required by the J2EE specification. For example, if a J2EE application needs to access multiple databases under a single transaction, it will not run properly on a J2EE product that does not support two-phase commit.