备忘录

记录学习过、研究过、使用过和总结过的内容,以备不时之需

统计

留言簿(4)

积分与排名

其它

技术网站

牛人博客

阅读排行榜

评论排行榜

一个典型的Spring的applicationcontext.xml配置文件(转)

<?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="sessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<property name="configLocation"
            value
="classpath:hibernate.cfg.xml">
        
</property>
    
</bean>
    
    
    
<!--  dao  -->
    
<bean id="AdminDAO" class="dao.AdminDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<bean id="OnlineDAO" class="dao.OnlineDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<bean id="BbsDAO" class="dao.BbsDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory"/>
        
</property>
    
</bean>
     
<bean id="CustomerDAO" class="dao.CustomerDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<bean id="DongtaiDAO" class="dao.DongtaiDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<bean id="ChanpinDAO" class="dao.ChanpinDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<bean id="DailijiamengDAO" class="dao.DailijiamengDAO">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
    
    
<!-- 配置TransactionManager -->
    
<bean id="myTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory" ref="sessionFactory" />
    
</bean>

    
<!-- 配置事务策略 -->
    
<tx:advice id="txAdvice" transaction-manager="myTxManager">
        
<tx:attributes>
            
<tx:method name="find*" propagation="REQUIRED"  read-only="true"/>
            
<tx:method name="save*" propagation="REQUIRED"/>
            
<tx:method name="update*" propagation="REQUIRED"/>
            
<tx:method name="delete*" propagation="REQUIRED"/>
            
<tx:method name="*" propagation="SUPPORTS" read-only="true" />
        
</tx:attributes>
    
</tx:advice>

    
<aop:config>
        
<aop:pointcut id="productServiceMethods" expression="execution(* service.*.*(..))" />
        
<aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods" />
    
</aop:config>
    
    
    
<bean id="managerSeveice" class="service.managerService"> 
        
<property name="adminDAO" ref="AdminDAO"/>
        
<property name="onlineDAO" ref="OnlineDAO"/>
        
<property name="bbsDAO" ref="BbsDAO"></property>
        
<property name="customerDAO" ref="CustomerDAO"></property>
        
<property name="dongtaiDAO" ref="DongtaiDAO"></property>
        
<property name="chanpinDAO" ref="ChanpinDAO"></property>
        
<property name="dailijiamengDAO" ref="DailijiamengDAO"></property>
    
</bean>
    
    
<bean id="base" class="com.lw.struts.action.BaseAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" >
        
<property name="mgr" ref="managerSeveice"></property>
    
</bean>
   
    
    
<!-- admin -->
    
<bean name="/manager_admin"
        class
="com.lw.struts.action.Manager_adminAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default">
        
<property name="mgr" ref="managerSeveice"></property>
    
</bean>    
    
<bean name="/manager_save_update_admin"
        class
="com.lw.struts.action.Manager_save_update_adminAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>    
    
<bean name="/manager_update_admin"
        class
="com.lw.struts.action.Manager_update_adminAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
    
<!-- online -->
    
<bean name="/manager_online"
        class
="com.lw.struts.action.Manager_onlineAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>    
    
<bean name="/manager_delete_online"
        class
="com.lw.struts.action.Manager_delete_onlineAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>    
    
<bean name="/manager_insert_online"
        class
="com.lw.struts.action.Manager_insert_onlineAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
    
<!-- bbs -->
    
<bean name="/manager_bbs"
        class
="com.lw.struts.action.Manager_bbsAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>
    
<bean name="/manager_delete_bbs"
        class
="com.lw.struts.action.Manager_delete_bbsAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>
    
<bean name="/manager_insert_bbs"
        class
="com.lw.struts.action.Manager_insert_bbsAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>
    
    
<!-- customer -->
    
<bean name="/manager_customer"
        class
="com.lw.struts.action.Manager_customerAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>
    
<bean name="/manager_insert_customer"
        class
="com.lw.struts.action.Manager_insert_customerAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_show_customer"
        class
="com.lw.struts.action.Manager_show_customerAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_delete_customer"
        class
="com.lw.struts.action.Manager_delete_customerAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
    
<!-- dongtai -->
    
<bean name="/manager_dongtai"
        class
="com.lw.struts.action.Manager_dongtaiAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>
    
<bean name="/manager_insert_dongtai"
        class
="com.lw.struts.action.Manager_insert_dongtaiAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_delete_dongtai"
        class
="com.lw.struts.action.Manager_delete_dongtaiAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_update_dongtai"
        class
="com.lw.struts.action.Manager_update_dongtaiAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_save_update_dongtai"
        class
="com.lw.struts.action.Manager_save_update_dongtaiAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
    
<!-- chanpin -->
    
<bean name="/manager_chanpin"
        class
="com.lw.struts.action.Manager_chanpinAction" abstract="false"
        lazy-init
="default" autowire="default" dependency-check="default" parent="base">
    
</bean>    
    
<bean name="/manager_delete_chanpin"
        class
="com.lw.struts.action.Manager_delete_chanpinAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_insert_chanpin"
        class
="com.lw.struts.action.Manager_insert_chanpinAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_update_chanpin"
        class
="com.lw.struts.action.Manager_update_chanpinAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_save_update_chanpin"
        class
="com.lw.struts.action.Manager_save_update_chanpinAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
    
<!-- dailijiameng -->
    
<bean name="/manager_dailijiameng"
        class
="com.lw.struts.action.Manager_dailijiamengAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_delete_dailijiameng"
        class
="com.lw.struts.action.Manager_delete_dailijiamengAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_insert_dailijiameng"
        class
="com.lw.struts.action.Manager_insert_dailijiamengAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_update_dailijiameng"
        class
="com.lw.struts.action.Manager_update_dailijiamengAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/manager_save_update_dailijiameng"
        class
="com.lw.struts.action.Manager_save_update_dailijiamengAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
<bean name="/testpage" class="com.lw.struts.action.TestpageAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default">
    
</bean>
    
    
<!-- login -->
    
<bean name="/mlogin" class="com.lw.struts.action.MloginAction"
        abstract
="false" lazy-init="default" autowire="default"
        dependency-check
="default" parent="base">
    
</bean>
    
</beans>

http://www.blogjava.net/ghyghost/archive/2007/12/07/166031.html

posted on 2009-03-19 17:21 雪山飞狐 阅读(451) 评论(0)  编辑  收藏 所属分类: 开源框架