HP Integrity NonStop J-Series User Manual

Page 355

Advertising
background image

<value>com.hp.empinfo.service.IEmployeeDao</value>
</property>
<property name = "target">
<ref bean = "empdao"/>
</property>
</bean>

5.

Bean Instance for the implementation class: It creates a bean for the implementation class and
contains a reference to the data source.

<bean id="empdao" class="com.hp.empinfo.service.EmployeeDao">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>

6.

XML namespace and schema location: The namespace and schema locations of the
<aop:config>

and <tx:advice> tags must be defined as follows:

xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop=http://www.springframework.org/schema/aop"

and

xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"

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

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="empdao" class="com.hp.empinfo.service.EmployeeDao">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id = "iempdao"
class = "org.springframework.aop.framework.ProxyFactoryBean">
<property name = "proxyInterfaces">
<value>com.hp.empinfo.service.IEmployeeDao</value>
</property>
<property name = "target">
<ref bean = "empdao"/>
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<aop:config>

Example of Using Spring Transaction Manager 355

Advertising
This manual is related to the following products: