数据加载中……
Spring 配置文件

product1.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"
>
<beans>

    
<bean id="productDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        
<property name="jndiName" value="java:comp/env/jdbc/product_skype"/>
    
</bean>


    
<bean id="productSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<property name="dataSource">
        
<ref local="productDataSource"/>
        
</property>

        
<property name="configLocations">
            
<list>
                
<value>classpath:avatar.cfg.xml</value>
                
<value>classpath:misc.cfg.xml</value>
            
</list>
        
</property>
    
</bean>

        
<!-- Transaction manager for Hibernate -->

    
<bean id="productTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory">
                
<ref bean="productSessionFactory"/>
        
</property>
    
</bean>

    
<!-- 接口实现声明-->

        
<bean id="productDAO" class="com.common.dao.impl.ProductDAO">
        
<property name="sessionFactory">
            
<ref bean="productSessionFactory"/>
        
</property>
    
</bean>
    
<!-- Declare transaction for Hibernate -->

    
<bean id="productTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        
<property name="transactionManager">
            
<ref bean="productTransactionManager"/>
        
</property>
        
<property name="transactionAttributeSource">
            
<value>
                com.joyinter.common.dao.impl.ProductDAO.save=PROPAGATION_REQUIRED
                com.joyinter.common.dao.impl.ProductDAO.update=PROPAGATION_REQUIRED
                com.joyinter.common.dao.impl.ProductDAO.delete=PROPAGATION_REQUIRED
                com.joyinter.common.dao.impl.ProductDAO.get*=PROPAGATION_REQUIRED,readOnly
                com.joyinter.common.dao.impl.ProductDAO.find*=PROPAGATION_REQUIRED,readOnly
            
</value>
        
</property>
    
</bean>

    
<!--接口代理设置-->
    
<bean id="productDAOProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
        
<property name="proxyInterfaces">
            
<value>com.joyinter.common.dao.DAO</value>
        
</property>
        
<property name="interceptorNames">
            
<list>
                
<value>productTransactionInterceptor</value>
                
<value>productDAO</value>
            
</list>
        
</property>
    
</bean>

    
<!-- ******************** global ******************** -->
    
<!-- global business object -->
    
<bean id="displayBO" class="com.common.business.DisplayBO">
        
<property name="avatarItemBO">
            
<ref bean="avatarItemBO"/>
        
</property>
        
<property name="avatarComponentBO">
            
<ref bean="avatarComponentBO"/>
        
</property>
        
<property name="miscItemBO">
            
<ref bean="miscItemBO"/>
        
</property>
    
</bean>

    
<!-- ******************** avatar ******************** -->
    
<!-- avatar base business object -->
    
<bean id="avatarCategoryBO" class="com.avatar.business.CategoryBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="avatarSubjectBO" class="com.avatar.business.SubjectBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="avatarItemBO" class="com.avatar.business.ItemBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="avatarComponentBO" class="com.avatar.business.ComponentBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<!-- avatar advance business object -->
    
<bean id="avatarBatchBO" class="com.avatar.business.BatchBO">
        
<property name="itemBO">
            
<ref bean="avatarItemBO"/>
        
</property>
    
</bean>

<!-- ******************** misc ******************** -->
    
<!-- misc base business object -->
    
<bean id="miscItemBO" class="com.misc.business.ItemBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="miscTypeBO" class="com.misc.business.TypeBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="miscBrandBO" class="com.misc.business.BrandBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>
    
<bean id="miscSubjectBO" class="com.misc.business.SubjectBO">
        
<property name="productDAO">
            
<ref bean="productDAOProxy"/>
        
</property>
    
</bean>

    
<!-- misc advance business object -->
    
<bean id="miscBatchBO" class="com.misc.business.BatchBO">
        
<property name="itemBO">
            
<ref bean="miscItemBO"/>
        
</property>
    
</bean>
    
<bean id="miscCustomBO" class="com.misc.business.CustomBO">
        
<property name="itemBO">
            
<ref bean="miscItemBO"/>
        
</property>
    
</bean>

</beans>


如配置多个文件,需在web.xml中加入:

 

  <context-param>
  
<param-name>contextConfigLocation</param-name>
  
<param-value>
   /WEB-INF/product1.xml,/WEB-INF/product2.xml
  
</param-value>
 
</context-param>
 
<listener>
  
<listener-class>
   org.springframework.web.context.ContextLoaderListener
  
</listener-class>
 
</listener>

 


struts-config.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<!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="itemday_form" type="com.joyinter.skype.statistic.bean.ItemDay"/>
        
<form-bean name="packitem_form" type="com.joyinter.skype.statistic.bean.PackItemPreview"/>

  
</form-beans>


  
<action-mappings>
  
<!-- ******************** stat ******************** -->
    
<action path="/itemDayAction" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" parameter="call" name="itemday_form">
         
<forward name="list_avatar" path="/avatar_custom_list.jsp"/>
         
<forward name="list_misc" path="/misc_list.jsp"/>
         
<forward name="test" path="/test1.jsp"/>
    
</action>
        
<action path="/packItemAction" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" parameter="call" name="itemday_form">
         
<forward name="listPackItem" path="/packitem_list.jsp"/>
    
</action>

  
</action-mappings>

  
<!-- 注册ContextLoaderPlugIn插件 -->

  
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
    
<set-property property="contextConfigLocation" value="/WEB-INF/struts.xml" />
  
</plug-in>
  
<message-resources parameter="ApplicationResources" />
</struts-config>

 

struts.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"
>
<beans>

<!--stat action映射-->
<bean id="/itemDayAction" class="com.joyinter.skype.statistic.action.ItemDayAction" >
    
<property name="itemDayBO">
        
<ref bean="itemDayBO"/>
    
</property>
        
<property name="avatarItemBO">
        
<ref bean="avatarItemBO"/>
    
</property>
</bean>

<bean id="/packItemAction" class="com.joyinter.skype.statistic.action.PackItemAction">
  
<property name="packItemBO">
    
<ref bean="packItemBO"/>
  
</property>
</bean>



</beans>

posted on 2007-08-15 15:53 当扎瓦 阅读(119) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: