<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean
name="sysTransportImportForm"
type="com.syaccp.sys.transport.forms.ConfigForm" />
<form-bean
name="sysTransportExportForm"
type="com.syaccp.sys.transport.forms.ConfigForm" />
</form-beans>
<action-mappings>
<action path="/sysTransportImport"
type="org.springframework.web.struts.DelegatingActionProxy"
name="sysTransportImportForm" attribute="sysTransportImportForm" scope="request"
parameter="method"
input="/hr/pm/hr_pm_target/target_import_edit.jsp">
<forward name="list"
path="/hr/pm/hr_pm_target/target_import_list.jsp" />
<forward name="view"
path="/hr/pm/hr_pm_target/target_import_view.jsp" />
<forward name="edit"
path="/hr/pm/hr_pm_target/target_import_edit.jsp" />
<forward name="success" path="/sysTransportImport.do?method=list"
redirect="true" />
</action>
<action path="/sysTransportExport"
type="org.springframework.web.struts.DelegatingActionProxy"
name="sysTransportExportForm" attribute="sysTransportExportForm" scope="request"
parameter="method"
input="/hr/pm/hr_pm_target/target_import_edit.jsp">
<forward name="list"
path="/hr/pm/hr_pm_target/target_import_list.jsp" />
<forward name="view"
path="/hr/pm/hr_pm_target/target_import_view.jsp" />
<forward name="edit"
path="/hr/pm/hr_pm_target/target_import_edit.jsp" />
<forward name="success" path="/sysTransportImport.do?method=list"
redirect="true" />
</action>
</action-mappings>
</struts-config>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >
<hibernate-configuration>
<session-factory>
<!-- 打开查询缓存 -->
<property name="cache.use_query_cache">true</property>
<!-- 打开二级缓存 -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<!--二级缓存的实现类 -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/ekp</property>
<property name="connection.username">root</property>
<property name="connection.password">qwnbc</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!--<property name="hibernate.current_session_context_class">thread</property>-->
<!-- 控制台上显示,格式化sql语句 -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- 控制台上显示,格式化sql语句 -->
<!-- hbm2ddl.auto:设置自动生成表结构-->
<property name="hbm2ddl.auto">create</property>
<!-- 测试hibernate继承映射 -->
<!-- <mapping resource="com/syaccp/common/extend/Extends1.hbm.xml"/> -->
<!-- <mapping resource="com/syaccp/common/extend/Extends2.hbm.xml"/> -->
<!-- <mapping resource="com/syaccp/common/extend/Extends3.hbm.xml"/> -->
<!-- 测试hibernate继承映射 -->
<!-- 要二级缓存必须指定要缓存的类 -->
<!-- 测试声明式事务 -->
<!--
<mapping resource="com/syaccp/fantasy/model/User.hbm.xml" />
<mapping resource="com/syaccp/fantasy/model/Log.hbm.xml" />
-->
<!-- 测试多对一转换
<mapping resource="com/syaccp/common/converter/test/HrPmAngle.hbm.xml" />
<mapping resource="com/syaccp/common/converter/test/SysOrgEmployee.hbm.xml" />
-->
</session-factory>
</hibernate-configuration>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- HrPmAngleAction 继承ExtendAction -->
<bean name="/hrPmAngle" class="com.syaccp.hr.pm.action.HrPmAngleAction" scope="prototype">
<property name="baseService" ref="hrPmAngleService"/>
</bean>
<!-- HrPmKpiClassAction 继承ExtendAction -->
<bean name="/hrPmKpiClass" class="com.syaccp.hr.pm.action.HrPmKpiClassAction" scope="prototype">
<property name="baseService" ref="hrPmKpiClassService"/>
</bean>
<!-- HrPmKpiAction 继承ExtendAction -->
<bean name="/hrPmKpi" class="com.syaccp.hr.pm.action.HrPmKpiAction" scope="prototype">
<property name="baseService" ref="hrPmKpiService"/>
</bean>
<!-- HrPmKpiTempletAction 继承ExtendAction -->
<bean name="/hrPmTemplet" class="com.syaccp.hr.pm.action.HrPmTempletAction" scope="prototype">
<property name="baseService" ref="hrPmTempletService"/>
</bean>
<!-- sysTransportImport 继承ExtendAction author 陈志成 -->
<bean name="/sysTransportImport" class="com.syaccp.sys.actions.SysTransportImportAction" scope="prototype">
<property name="baseService" ref="sysTransportImportService"/>
</bean>
<bean name="/sysTransportExport" class="com.syaccp.sys.actions.SysTransPortExportAction" scope="prototye">
<property name="baseService" ref="sysTransportExportService"></property>
</bean>
<bean name="/hrPmActionTemplet" class="com.syaccp.hr.pm.action.HrPmActionTempletAction" scope="prototype">
<property name="baseService" ref="hrPmActionTempletService"/>
</bean>
<bean name="/hrPmAction" class="com.syaccp.hr.pm.action.HrPmActionTableAction" scope="prototype">
<property name="baseService" ref="hrPmActionTableService"/>
</bean>
</beans>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!--
<bean id="securityProxy" class="com.syaccp.common.dyproxy.SecurityHandle">
<property name="targetObject" ref="baseService"/>
</bean>
-->
<!-- 考核维度业务实现类 继承BaseServiceImpl -->
<bean id="hrPmAngleService"
class="com.syaccp.common.service.HrPmAngleServiceImpl">
<property name="baseDAO" ref="hrPmAngleDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标分类业务实现类 继承BaseServiceImpl -->
<bean id="hrPmKpiClassService"
class="com.syaccp.common.service.HrPmKpiClassServiceImpl">
<property name="baseDAO" ref="hrPmKpiClassDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标库业务实现类 继承BaseServiceImpl -->
<bean id="hrPmKpiService"
class="com.syaccp.common.service.HrPmKpiServiceImpl">
<property name="baseDAO" ref="hrPmKpiDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmTempletService"
class="com.syaccp.common.service.HrPmTempletServiceImpl">
<property name="baseDAO" ref="hrPmTempletDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标库导入业务实现类 继承 BaseServiceImpl-->
<bean id="sysTransportImportService"
class="com.syaccp.common.service.SysTransPortImportServiceImpl">
<property name="baseDAO" ref="sysTransportImportDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="sysTransportExportService"
class="com.syaccp.common.service.SysTransPortExportServiceImpl">
<property name="baseDAO" ref="sysTransportExportDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmActionTempletService"
class="com.syaccp.common.service.HrPmActionTempletServiceImpl">
<property name="baseDAO" ref="hrPmActionTempletDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmActionTableService"
class="com.syaccp.common.service.HrPmActionTableServiceImpl">
<property name="baseDAO" ref="hrPmActionTableDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!--
org.apache.commons.dbcp.BasicDataSource:只适合于简单的单机连接机制
org.springframework.jdbc.datasource.DriverManagerDataSource:使用DBCP能获得连接池的功能
但需要将commons-dbcp.jar,commons-pool.jar,commonscollections.jar包导入
-->
<!-- spring,hibernate集成 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/ekp"/>
<property name="username" value="root"/>
<property name="password" value="qwnbc"/>
</bean>
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="com.syaccp.common.config.LoadHibernateConfig">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<!-- 获取hibernate配置信息以及相关映射文件 注意:configLocation的返回类型是
Resource:说明要配置classpath 用value标签
-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 基础DAO实现类 -->
<bean id="baseDAO" class="com.syaccp.common.impl.BaseDAOImpl">
<property name="modelClassName" value="com.syaccp.hr.pm.models.HrPmAngle"/>
<property name="template" ref="hibernateTemplate"/>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 第一种配置方式 -->
<!--
代理类:TransactionProxyFactoryBean
弊端:
1.每个目标类都需要一个代理
2.目标类中每个方法都要进行权限判断;(代码重复!)
-->
<!--
<bean id="baseServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="proxyInterfaces">
<list>
<value>com.syaccp.common.inter.IBaseDAO</value>
</list>
</property>
<property name="target" ref="baseService"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_NESTED</prop>
<prop key="find*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
-->
<!-- 第二种配置方式 -->
<!--
代理类:TransactionInterceptor
弊端:
-->
<!--
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_NESTED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>baseService</value>
<value>hrPmAngleService</value>
<value>hrPmKpiService</value>
<value>hrPmKpiClassService</value>
<value>hrPmTempletService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
-->
<!-- 第三种配置方式 -->
<!-- 配置事务传播特性 read-only:其他方法不必进行脏数据检查,或更新(可以优化,提高效率) -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true" rollback-for="-"/>
</tx:attributes>
</tx:advice>
<!-- 哪里类的哪些方法参与事务-->
<aop:config>
<aop:pointcut id="allServiceMethod" expression="execution(* com.syaccp.common.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/>
</aop:config>
</beans>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean
name="sysTransportImportForm"
type="com.syaccp.sys.transport.forms.ConfigForm" />
<form-bean
name="sysTransportExportForm"
type="com.syaccp.sys.transport.forms.ConfigForm" />
</form-beans>
<action-mappings>
<action path="/sysTransportImport"
type="org.springframework.web.struts.DelegatingActionProxy"
name="sysTransportImportForm" attribute="sysTransportImportForm" scope="request"
parameter="method"
input="/hr/pm/hr_pm_target/target_import_edit.jsp">
<forward name="list"
path="/hr/pm/hr_pm_target/target_import_list.jsp" />
<forward name="view"
path="/hr/pm/hr_pm_target/target_import_view.jsp" />
<forward name="edit"
path="/hr/pm/hr_pm_target/target_import_edit.jsp" />
<forward name="success" path="/sysTransportImport.do?method=list"
redirect="true" />
</action>
<action path="/sysTransportExport"
type="org.springframework.web.struts.DelegatingActionProxy"
name="sysTransportExportForm" attribute="sysTransportExportForm" scope="request"
parameter="method"
input="/hr/pm/hr_pm_target/target_import_edit.jsp">
<forward name="list"
path="/hr/pm/hr_pm_target/target_import_list.jsp" />
<forward name="view"
path="/hr/pm/hr_pm_target/target_import_view.jsp" />
<forward name="edit"
path="/hr/pm/hr_pm_target/target_import_edit.jsp" />
<forward name="success" path="/sysTransportImport.do?method=list"
redirect="true" />
</action>
</action-mappings>
</struts-config>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >
<hibernate-configuration>
<session-factory>
<!-- 打开查询缓存 -->
<property name="cache.use_query_cache">true</property>
<!-- 打开二级缓存 -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<!--二级缓存的实现类 -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/ekp</property>
<property name="connection.username">root</property>
<property name="connection.password">qwnbc</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!--<property name="hibernate.current_session_context_class">thread</property>-->
<!-- 控制台上显示,格式化sql语句 -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- 控制台上显示,格式化sql语句 -->
<!-- hbm2ddl.auto:设置自动生成表结构-->
<property name="hbm2ddl.auto">create</property>
<!-- 测试hibernate继承映射 -->
<!-- <mapping resource="com/syaccp/common/extend/Extends1.hbm.xml"/> -->
<!-- <mapping resource="com/syaccp/common/extend/Extends2.hbm.xml"/> -->
<!-- <mapping resource="com/syaccp/common/extend/Extends3.hbm.xml"/> -->
<!-- 测试hibernate继承映射 -->
<!-- 要二级缓存必须指定要缓存的类 -->
<!-- 测试声明式事务 -->
<!--
<mapping resource="com/syaccp/fantasy/model/User.hbm.xml" />
<mapping resource="com/syaccp/fantasy/model/Log.hbm.xml" />
-->
<!-- 测试多对一转换
<mapping resource="com/syaccp/common/converter/test/HrPmAngle.hbm.xml" />
<mapping resource="com/syaccp/common/converter/test/SysOrgEmployee.hbm.xml" />
-->
</session-factory>
</hibernate-configuration>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- HrPmAngleAction 继承ExtendAction -->
<bean name="/hrPmAngle" class="com.syaccp.hr.pm.action.HrPmAngleAction" scope="prototype">
<property name="baseService" ref="hrPmAngleService"/>
</bean>
<!-- HrPmKpiClassAction 继承ExtendAction -->
<bean name="/hrPmKpiClass" class="com.syaccp.hr.pm.action.HrPmKpiClassAction" scope="prototype">
<property name="baseService" ref="hrPmKpiClassService"/>
</bean>
<!-- HrPmKpiAction 继承ExtendAction -->
<bean name="/hrPmKpi" class="com.syaccp.hr.pm.action.HrPmKpiAction" scope="prototype">
<property name="baseService" ref="hrPmKpiService"/>
</bean>
<!-- HrPmKpiTempletAction 继承ExtendAction -->
<bean name="/hrPmTemplet" class="com.syaccp.hr.pm.action.HrPmTempletAction" scope="prototype">
<property name="baseService" ref="hrPmTempletService"/>
</bean>
<!-- sysTransportImport 继承ExtendAction author 陈志成 -->
<bean name="/sysTransportImport" class="com.syaccp.sys.actions.SysTransportImportAction" scope="prototype">
<property name="baseService" ref="sysTransportImportService"/>
</bean>
<bean name="/sysTransportExport" class="com.syaccp.sys.actions.SysTransPortExportAction" scope="prototye">
<property name="baseService" ref="sysTransportExportService"></property>
</bean>
<bean name="/hrPmActionTemplet" class="com.syaccp.hr.pm.action.HrPmActionTempletAction" scope="prototype">
<property name="baseService" ref="hrPmActionTempletService"/>
</bean>
<bean name="/hrPmAction" class="com.syaccp.hr.pm.action.HrPmActionTableAction" scope="prototype">
<property name="baseService" ref="hrPmActionTableService"/>
</bean>
</beans>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!--
<bean id="securityProxy" class="com.syaccp.common.dyproxy.SecurityHandle">
<property name="targetObject" ref="baseService"/>
</bean>
-->
<!-- 考核维度业务实现类 继承BaseServiceImpl -->
<bean id="hrPmAngleService"
class="com.syaccp.common.service.HrPmAngleServiceImpl">
<property name="baseDAO" ref="hrPmAngleDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标分类业务实现类 继承BaseServiceImpl -->
<bean id="hrPmKpiClassService"
class="com.syaccp.common.service.HrPmKpiClassServiceImpl">
<property name="baseDAO" ref="hrPmKpiClassDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标库业务实现类 继承BaseServiceImpl -->
<bean id="hrPmKpiService"
class="com.syaccp.common.service.HrPmKpiServiceImpl">
<property name="baseDAO" ref="hrPmKpiDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmTempletService"
class="com.syaccp.common.service.HrPmTempletServiceImpl">
<property name="baseDAO" ref="hrPmTempletDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 指标库导入业务实现类 继承 BaseServiceImpl-->
<bean id="sysTransportImportService"
class="com.syaccp.common.service.SysTransPortImportServiceImpl">
<property name="baseDAO" ref="sysTransportImportDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="sysTransportExportService"
class="com.syaccp.common.service.SysTransPortExportServiceImpl">
<property name="baseDAO" ref="sysTransportExportDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmActionTempletService"
class="com.syaccp.common.service.HrPmActionTempletServiceImpl">
<property name="baseDAO" ref="hrPmActionTempletDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="hrPmActionTableService"
class="com.syaccp.common.service.HrPmActionTableServiceImpl">
<property name="baseDAO" ref="hrPmActionTableDAO" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
<?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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!--
org.apache.commons.dbcp.BasicDataSource:只适合于简单的单机连接机制
org.springframework.jdbc.datasource.DriverManagerDataSource:使用DBCP能获得连接池的功能
但需要将commons-dbcp.jar,commons-pool.jar,commonscollections.jar包导入
-->
<!-- spring,hibernate集成 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/ekp"/>
<property name="username" value="root"/>
<property name="password" value="qwnbc"/>
</bean>
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="com.syaccp.common.config.LoadHibernateConfig">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<!-- 获取hibernate配置信息以及相关映射文件 注意:configLocation的返回类型是
Resource:说明要配置classpath 用value标签
-->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 基础DAO实现类 -->
<bean id="baseDAO" class="com.syaccp.common.impl.BaseDAOImpl">
<property name="modelClassName" value="com.syaccp.hr.pm.models.HrPmAngle"/>
<property name="template" ref="hibernateTemplate"/>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 第一种配置方式 -->
<!--
代理类:TransactionProxyFactoryBean
弊端:
1.每个目标类都需要一个代理
2.目标类中每个方法都要进行权限判断;(代码重复!)
-->
<!--
<bean id="baseServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<property name="proxyInterfaces">
<list>
<value>com.syaccp.common.inter.IBaseDAO</value>
</list>
</property>
<property name="target" ref="baseService"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_NESTED</prop>
<prop key="find*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
-->
<!-- 第二种配置方式 -->
<!--
代理类:TransactionInterceptor
弊端:
-->
<!--
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_NESTED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>baseService</value>
<value>hrPmAngleService</value>
<value>hrPmKpiService</value>
<value>hrPmKpiClassService</value>
<value>hrPmTempletService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
-->
<!-- 第三种配置方式 -->
<!-- 配置事务传播特性 read-only:其他方法不必进行脏数据检查,或更新(可以优化,提高效率) -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true" rollback-for="-"/>
</tx:attributes>
</tx:advice>
<!-- 哪里类的哪些方法参与事务-->
<aop:config>
<aop:pointcut id="allServiceMethod" expression="execution(* com.syaccp.common.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/>
</aop:config>
</beans>