程序配置相关

一、spring-base.xml
    <!--
    *1、
    *http://blog.csdn.net/chunqiuwei/article/details/16115135
    *扫描com.glodon包下的文件,如果扫描到有@Component @Controller@Service等这些注解的类,
    *则把这些类注册为bean
    *2、这样代码中就可以使用@Autowired自动注解了    
    * @Autowired
    * EtlProjService projService;
    -->
    <context:component-scan base-package="com.glodon" />
    <!--事务相关-->
      <!--定义sessionFactory-->
    <bean id="sessionFactoryForgix"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="configLocation">
             <!-- 引用hibernate.cfg.xml配置文件 -->
             <value>classpath:com/glodon/gixdb/config/hibernate.cfg.xml</value>
        </property>
    </bean>
   
    <!-- 事务配置 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactoryForgix" />
    </bean>    
    
    <!-- 配置事务的传播特性,哪些方法需要添加事务 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="del*" propagation="REQUIRED" />
            <tx:method name="remove*" propagation="REQUIRED" />
            <tx:method name="init*" propagation="REQUIRED" />
            <tx:method name="reset*" propagation="REQUIRED" />
            <!-- 数据导入 -->
             <tx:method name="import*" propagation="REQUIRED" />
            <!-- 数据转换 -->
             <tx:method name="trans*" propagation="REQUIRED" />
             <!-- 数据恢复-->
             <tx:method name="restore*" propagation="REQUIRED" />
             <tx:method name="copy*" propagation="REQUIRED" />
             <tx:method name="replace*" propagation="REQUIRED" />
             <tx:method name="open*" propagation="REQUIRED" />
             <!-- 数据校验 -->
             <tx:method name="check*" propagation="REQUIRED" />
             <tx:method name="getOrInitial*" propagation="REQUIRED" />
             <!-- 浏览pentaho报表的时候要和数据库中的报表同步  -->
             <tx:method name="browsePentahoRepository" propagation="REQUIRED" />
             <tx:method name="rename*" propagation="REQUIRED" />
             <tx:method name="*" read-only="true" />
        </tx:attributes>
    </tx:advice>

    <!-- 那些类的哪些方法参与事务 -->
    <aop:config>
        <!--
        expression说明:expression="execution(public * com.glodon.gix..*Service.*(..))"
        public : 方法定义的关键字
        *  :返回值类型,*代表任何类型
        com.glodon.gix.. :扫描com.glodon.gix包下面的任意子级别包下的文件,
        *Service.   :文件的后缀名需要是Service结尾的
        *(..) :  * 表示任何方法,括号内两个点,代表方法内任何参数
        -->
        <aop:pointcut id="allServiceMethod" expression="execution(public * com.glodon.gix..*Service.*(..))" />
        <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
    </aop:config>
    <aop:aspectj-autoproxy proxy-target-class="true"/>        
    
    
    <!-- 配置jindi数据源-->
    <bean name="gixDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:gix5ds</value>
        </property>
    </bean>    
二、装饰器:sitemesh.xml
    1、D:\workspace\costdb\gix5\web\WEB-INF\sitemesh.xml
    2、内容解析
      <!-- 引入配置文件 -->
      <property name="decorators-file" value="/WEB-INF/decorators.xml"/>
    3、D:\workspace\costdb\gix5\web\WEB-INF\decorators.xml      
       <decorators defaultdir="/decorators">
            <!-- 不需要过滤的页面 -->
            <excludes>
                <pattern>/index.jsp</pattern>
            </excludes>
            
            
            <decorator name="template" page="gix_template.vm">
                <!--  <pattern>/demo/demo!toupload.do</pattern>  -->
                <pattern>/mdl/mdlresdimoption!demo.do</pattern>
                <pattern>/mdl/mdlindividualitems!main.do</pattern>
                <pattern>/mdl/mdldimensionset!main.do</pattern>
                <pattern>/mdl/stage-model!showStageModels.do</pattern>
                <pattern>/mdl/single-model!showSingleModels.do</pattern>
                <pattern>/mdl/mdl-pivot-model!analysispage.do</pattern>
                <pattern>/mdl/mdlbaicjfee!showmdlprojfee.do</pattern>            
                </decorators>
            <decorator>
    4、装饰中的模板文件:gix_template.vm
           <body>
        <!-- gix_top.vm:装饰网页的头部 -->
        #parse("decorators/gix_top.vm")   
        <div class="botx">
            <div class="topbox_est">
                <!-- 装饰网页的左边 -->
                #parse("decorators/gix_template_leftnav.vm")   
                <div class="subjereig">
                    <!-- $body  这里就是需要装饰的网址内容存放区 -->
                    $body    
                </div>
            <div style="clear:both"></div>
            </div>
        </div>
        <!-- 装饰网页的下面 -->
        #parse("WEB-INF/view/mdl/mdl_commons.vm")
        #parse("decorators/gix_foot.vm")
        </body>

posted @ 2015-01-04 09:54  SouthAurora  Views(149)  Comments(0)    收藏  举报