For programmatic transaction, Modifying the applicationcontext.xml file – HP Integrity NonStop J-Series User Manual

Page 356

Advertising
background image

<aop:pointcut id="empdaoOperation"
expression="execution(* com.hp.empinfo.service.EmployeeDao.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="empdaoOperation"/>
</aop:config>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="connectionProperties">
<props>
<prop key="catalog">
${jdbc.catalog}
</prop>
<prop key="schema">
${jdbc.schema}
</prop>
</props>
</property>

For Programmatic Transaction

This section describes only the PlatformTransactionManager implementation for Programmatic
Transaction.

Modifying the applicationContext.xml File

Modify the applicationContext.xml file to include the bean definition for the transaction
manager class.

NOTE:

Because the EmpInfo application contains only JDBC operations,

org.springframework.jdbc.datasource.DataSourceTransactionManager

is used

as the transaction manager class.

Add the following lines of code to include the bean definition for the transaction manager class:

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

After modification, the applicationContext.xml file should appear as:

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">

356 Using Spring Transaction Manager

Advertising
This manual is related to the following products: