读书人

spring的配备化

发布时间: 2012-09-17 12:06:51 作者: rapoo

spring的配置化
<?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"
>

<!-- 配置jndi数据源 --><!--
<bean id="dataSource" ref="sessionFactory"></property><!-- 把sessionFactory工厂注入到模板 -->
</bean>
<!-- hibernateTemplate事务事务管理 jdbc:"org.springframework.jdbc.datasource.DataSourceTransactionManager -->
<bean id="transactionManager" ref="sessionFactory"></property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 配置哪些方法是要通过事务来管理 -->
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>

<aop:config>
<!-- 定义一个切入点 -->
<aop:pointcut id="mypointcut" expression="execution(* cn.com.kxrj.manager.impl.*.*(..)))"/>
<aop:advisor pointcut-ref="mypointcut" advice-ref="txAdvice"/>
</aop:config>




<!-- 启用AspectJ的支持 这里一定要写,-->
<aop:aspectj-autoproxy />
<!-- 创建切面类
<bean id="beforeAdviceLog"
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="template" abstract="true" lazy-init="true">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="baseDAO" parent="template">
</bean>

<!-- *******管理员信息管理******* -->

<bean id="adminDAO" parent="template">
</bean>

<!-- *******日信息管理******* -->
<bean id="logDAO" parent="template">
</bean>

<!-- *******行业实体信息管理******* -->
<bean id="industryDAO" parent="template">
</bean>

<!-- ******* 产品供应信息管理******* -->
<bean id="productSupplyDAO" parent="template">
</bean>

<!-- ******* 会员产品实体信息管理******* -->
<bean id="userProductDAO" parent="template">
</bean>

<!-- ******* 标题类别实体信息管理******* -->
<bean id="sortDAO" parent="template">
</bean>

<!-- ******* 标题栏实体信息管理******* -->
<bean id="titleDAO" parent="template">
</bean>

<!-- ******* 企业/居民信息管理******* -->
<bean id="enterpriseDAO" parent="template">
</bean>

<!-- ****** 工商指南类别管理******* -->
<bean id="commerceDAO" parent="template">
</bean>


<!-- ******* 工商指南类别详细信息管理******* -->
<bean id="detailedCommerceDAO" parent="template">
</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">

<!-- *********************************后台管理************************************** -->
<!-- 管理员管理 manager-->
<bean id="adminManager"
ref="adminDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 日志管理 manager-->
<bean id="logManager"
ref="logDAO"></property>
</bean>




<!-- *********************** 会员管理manager ************************ -->

<!-- 会员信息 -->
<bean id="userManager" ref="userDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 会员产品信息 -->
<bean id="userProductManager" ref="userProductDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 产品供应信息-->
<bean id="productSupplyManager" ref="productSupplyDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 行业信息 -->
<bean id="industryManager" ref="industryDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>


<!-- ******************** 工商指南信息管理************************************************************** -->
<!-- 工商指南标题信息 -->
<bean id="titleManager" ref="titleDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 工商标题类别详情信息 -->
<bean id="sortManager" ref="sortDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 工商指南类别信息 -->
<bean id="commerceManager" ref="commerceDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</bean>

<!-- 工商指南类别详细信息 -->
<bean id="detailedCommerceManager" ref="detailedCommerceDAO"></property>
<property name="logDAO" ref="logDAO"></property>
</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="adminAction"
ref="adminManager" />
</bean>

<bean id="logAction"
ref="logManager" />
</bean>

<!-- ****************会员管理类action****************** -->
<!-- 会员信息 -->
<bean id="userAction" ref="userManager"></property>
</bean>
<!-- 会员产品 -->
<bean id="userProductAction" ref="userProductManager"></property>
</bean>
<!-- 产品供应信息 -->
<bean id="productSupplyAction" ref="productSupplyManager"></property>
</bean>
<!-- 行业信息 -->
<bean id="industryAction" ref="industryManager"></property>
</bean>


<!-- ****************工商指南管理类action****************** -->

<!-- 工商指南标题信息 -->
<bean id="titleAction" ref="titleManager"></property>
</bean>
<!-- 工商标题类别详细信息 -->
<bean id="sortAction" ref="sortManager"></property>
</bean>

<!-- 工商指南类别信息 -->
<bean id="commerceAction" ref="commerceManager"></property>
</bean>

<!-- 工商指南类别详细信息 -->
<bean id="detailedCommerceAction" ref="detailedCommerceManager"></property>
</bean>




</beans>

读书人网 >软件架构设计

热点推荐