Java Reference
In-Depth Information
DataSourceTransactionManager is configured with a JDBC DataSource . When
called by the TransactionInterceptor to begin a transaction, it gets a connection
from the DataSource and ensures that auto-commit is disabled. It also binds the
JDBC connection to the thread for use by the SqlMapClientTemplate . Later when
it is called by the TransactionInterceptor to commit the transaction, the Data-
SourceTransactionManager calls Connection.commit() , closes the connection, and
unbinds it from the thread.
Making the transaction scripts transactional is easy. In the Spring bean defini-
tions you configure a TransactionInterceptor to use a DataSourceTransaction-
Manager and apply it to the transaction script class. Let's see how to do this.
9.5.2
The Spring bean definitions
Figure 9.9 shows the Spring beans that we must define to configure the Place-
OrderTransactionScripts class and make it transactional. In addition to configur-
ing the TransactionInterceptor bean, it defines beans for the DAO s and the
SqlMapClient and SqlMapClientTemplate classes.
PlaceOrder
Transaction
ScriptsProxy
Creator
Presentation Tier
PlaceOrder
Transaction
Scripts
Transaction
Interceptor
APPLICATION
CLASSES
DataSource
PendingOrder
DAO
RestaurantDAO
Transaction
Manager
SPRING
FRAMEWORK
CLASSES
SqlMapClient
Template
iBATIS CLASSES
SqlMapClient
Figure 9.9
The Spring beans required to deploy the
PlaceOrderTransactionScripts
JDBC CLASSES
DataSource
 
 
Search WWH ::




Custom Search