app<?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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!-- 配置session工厂 -->
<!--方式1:直接读取hibernate.cfg.xml -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!--添加声明式事务 -->
<!--定义一个事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--定义事务规则 -->
<aop:config>
<aop:pointcut id="mypoint" expression="execution(* cn.jbit.ssh.service..*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="mypoint"/>
</aop:config>
<!-- 事务增强 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!-- Dept设置 -->
<!--dao 配置 -->
<!-- scope是作用域,默认的是singelton(单例模式),建议用prototype(每次请求时都创建一个新的bean)
request(每次请求创建一个新的实例,需要在webxml下配置监听),session和globalsession() -->
<bean id="deptDao" class="cn.jbit.ssh.dao.impl.DeptDaoImpl" scope="prototype">
<property name="sessionFactory" ref="sessionFactory" ></property>
</bean>
<!--service配置 -->
<bean id="deptService" class="cn.jbit.ssh.service.impl.DeptServiceImpl">
<property name="dao" ref="deptDao"></property>
</bean>
<!-- acion配置 -->
<bean id="deptAction" class="cn.jbit.ssh.action.DeptAction">
<property name="deptService" ref="deptService"></property>
</bean>
</beans>
<!-- / -->
<!-- 单词 -->
<!-- propagation[,prɒpə'ɡeɪʃən]传播;繁殖;增殖 -->
<!-- transaction[træn'zækʃ(ə)n; trɑːn-; -'sæk-]n. 交易;事务;办理;会报,学报 -->
<!-- scope[skəʊp]范围;余地;视野;眼界;导弹射程 -->
<!-- prototype['prəʊtətaɪp]原型;标准,模范 -->
<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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!-- 配置session工厂 -->
<!--方式1:直接读取hibernate.cfg.xml -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!--添加声明式事务 -->
<!--定义一个事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--定义事务规则 -->
<aop:config>
<aop:pointcut id="mypoint" expression="execution(* cn.jbit.ssh.service..*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="mypoint"/>
</aop:config>
<!-- 事务增强 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ -->
<!-- Dept设置 -->
<!--dao 配置 -->
<!-- scope是作用域,默认的是singelton(单例模式),建议用prototype(每次请求时都创建一个新的bean)
request(每次请求创建一个新的实例,需要在webxml下配置监听),session和globalsession() -->
<bean id="deptDao" class="cn.jbit.ssh.dao.impl.DeptDaoImpl" scope="prototype">
<property name="sessionFactory" ref="sessionFactory" ></property>
</bean>
<!--service配置 -->
<bean id="deptService" class="cn.jbit.ssh.service.impl.DeptServiceImpl">
<property name="dao" ref="deptDao"></property>
</bean>
<!-- acion配置 -->
<bean id="deptAction" class="cn.jbit.ssh.action.DeptAction">
<property name="deptService" ref="deptService"></property>
</bean>
</beans>
<!-- / -->
<!-- 单词 -->
<!-- propagation[,prɒpə'ɡeɪʃən]传播;繁殖;增殖 -->
<!-- transaction[træn'zækʃ(ə)n; trɑːn-; -'sæk-]n. 交易;事务;办理;会报,学报 -->
<!-- scope[skəʊp]范围;余地;视野;眼界;导弹射程 -->
<!-- prototype['prəʊtətaɪp]原型;标准,模范 -->