Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Trong phần này, chúng tôi sẽ bao gồm những hình thức phân giới cắm mốc giao dịch là một phần của việc phát hành mùa xuân 1,0. Sau đó phát hành mùa xuân thêm các hình thức khác, đáng chú ý nhất là mùa xuân 2,0. Tuy nhiên, phát triển toàn diện mùa xuân nên được nhận thức của các hình thức cũ, | 196 CHAPTER 7 TRANSACTION MANAGEMENT Transaction Demarcation Introduced in Spring 1.0 In this section we ll cover those forms of transaction demarcation that were part of the Spring 1.0 release. Later Spring releases added other forms most notably Spring 2.0. However all-round Spring developers should be aware of these older forms as they have been in common use for many years. Also other transaction-demarcation mechanisms reuse the components that are introduced here. Transactioninterceptor and Proxy Creation The core AOP component in all forms of transaction demarcation is the org.springframework. transaction.interceptor.TransactionInterceptor class. It s an around advice that implements the Methodinterceptor interface see Chapter 3 . Transactioninterceptor is a thread-safe class that starts a transaction before a method is executed and ends it after the method execution exits. Listing 7-3 shows the configuration of Transactioninterceptor in a Spring XML file. Listing 7-3. Configuring Transactioninterceptor beans bean id dataSource class org.apache.commons.dbcp.BasicDataSource destroy-method close property name driverClassName value jdbc.driverClassName property name url value jdbc.url property name username value jdbc.username property name password value jdbc.password bean bean class org.springframework.beans.factory.config. PropertyPlaceholderConfigurer property name location value classpath jdbc.properties bean bean id transactionManager class org.springframework.jdbc.datasource. DataSourceTransactionManager property name dataSource ref dataSource bean bean id transactionInterceptor class org.springframework.transaction.interceptor.TransactionInterceptor property name transactionManager ref transactionManager property name transactionAttributes props prop key endMatch PROPAGATION_REQUIRED prop props property bean beans The transactioninterceptor bean in Listing 7-3 is an around advice configured to use the DataSourceTransactionManager. The other property .