HP Integrity NonStop H-Series User Manual
Page 377

4.
AOP Proxy Factory Bean: It creates an AOP proxy factory bean that contains the business
interface and the implementation class as the target.
<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>
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>
<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"
destroy-method="close">
Example of Using Spring Transaction Manager
377