<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 链接数据库-->
<bean id="sql" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</property>
<property name="url">
<value>jdbc:sqlserver://localhost:1433;databaseName=user_text</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="maxActive">
<value>100</value>
</property>
</bean>
<!-- 结束-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="sql" />
</property>
<!--2级缓存-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- 开启缓存 -->
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<!-- 指定 提供商 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
<!--2结束-->
<!--数据库实体映射文件-->
<property name="mappingResources">
<list>
<value>cn/jb/entity/TblUser.hbm.xml</value>
</list>
</property>
<!--数据库实体映射文件结束-->
</bean>
<!--action 开始-->
<bean name="/user" class="cn.jb.struts.action.UserAction">
<property name="tblUserBiz" ref="tblUserBiz" />
</bean>
<!--action 结束-->
<!--Biz 开始-->
<bean id="tblUserBizImpl" class="cn.jb.biz.impl.TblUserBizImpl">
<property name="tblUserDAO" ref="tblUserDAOImpl"/>
</bean>
<!--Biz 结束-->
<!--Dao开始-->
<bean id="tblUserDAOImpl" class="cn.jb.dao.impl.TblUserDAOImpl">
<!--Dao 结束--> <property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- AOP -->
<bean id="logAdviceBefore" class="cn.jb.common.LogAdviceBefore" />
<bean id="logAdviceAfter" class="cn.jb.common.LogAdviceAfter" />
<bean id="tblUserBiz" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>cn.jb.biz.TblUserBiz</value>
</property>
<property name="interceptorNames">
<list>
<value>logAdviceBefore</value>
<value>logAdviceAfter</value>
</list>
</property>
<property name="target" ref="tblUserBizImpl" />
</bean>
<!-- 声明式事务 -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<tx:advice id="txAdvice"
transaction-manager="myTransactionManager">
<tx:attributes>
<tx:method name="find*" propagation="REQUIRED"
read-only="true" />
<tx:method name="get*" propagation="REQUIRED"
read-only="true" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="serviceMethods"
expression="execution(* cn.jb.biz.*.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="serviceMethods" />
</aop:config>
</beans>