Spring provides a rich set of implementations for the PlatformTransactionManager interface. The
CciLocalTransactionManager class supports JEE JCA and the Common Client Interface (CCI). The
DataSourceTransactionManager class is for generic JDBC connections. For the ORM side, there are a
number of implementations, including JDO (JdoTransactionManager class), JPA (JpaTransactionManager
class), and Hibernate 3 and Hibernate 4 (HibernateTransactionManager with different package names).
For JMS, the implementations include JMS 1.1 or newer (JmsTransactionManager class) and JMS 1.0.2
(JmsTransactionManager102 class). For JTA, the generic implementation class is the
JtaTransactionManager class. Spring also provides several JTA transaction manager classes that are
specific to particular application servers. Those classes provide native support for WebSphere
(WebSphereUowTransactionManager class), WebLogic (WebLogicJtaTransactionManager class), and Oracle
OC4J (OC4JJtaTransactionManager class).
Analyzing Transaction Properties
In this section, we will discuss the transaction properties that Spring supports, focusing on interacting
with RDBMS as the backend resource.
Transactions have the four notoriously known ACID properties--atomicity, consistency, isolation,
and durability--and it is up to the transactional resources to maintain these aspects of a transaction.
You cannot control the atomicity, consistency, and durability of a transaction, but you can control the
transaction propagation and timeout, as well as configure whether the transaction should be read-only
and specify the isolation level.
Spring encapsulates all these settings in a TransactionDefinition interface. This interface is used in
the core interface of the transaction support in Spring, the PlatformTransactionManager interface, whose
implementations perform transaction management on a specific platform, such as JDBC or JTA. The
core method, PlatformTransactionManager.getTransaction(), takes a TransactionDefinition interface
as an argument and returns a TransactionStatus interface. The TransactionStatus interface is used to
control the transaction execution, more specifically to set the transaction result and to check whether
the transaction is completed or whether it is a new transaction.
The TransactionDefinition Interface
As we mentioned earlier, the TransactionDefinition interface controls the properties of a transaction.
Let's take a more detailed look at the TransactionDefinition interface (see Listing 13-1) and describe its
methods.
Listing 13-1. TransactionDefinition Interface
package org.springframework.transaction;
import java.sql.Connection;
public interface TransactionDefinition {
// Variable declaration statements omitted
int getPropagationBehavior();
int getIsolationLevel();
int getTimeout();
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home