`
comeon-liming
  • 浏览: 47464 次
  • 性别: Icon_minigender_1
  • 来自: 大连
最近访客 更多访客>>
社区版块
存档分类
最新评论

freemarker+velocity+jsf+spring+hibernate 初探一

    博客分类:
  • java
阅读更多

     喜欢架构方面的东西,在一年多以前就开始接触freemarker,velocity,jsf,spring....,很遗憾现在才开始做这方面的整合。在网上很少看到jsf与模板技术同使用的例子,都说jsf速度不太理想,我想jsf与模块引擎结合一定会给我们带来惊喜。

    下面介绍一下这方面的研究成果。

    首先从web.xml开始吧!

 

xml 代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans  
  3.     xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  
  6.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  7.         <property name="sessionFactory">  
  8.             <ref bean="sessionFactory"/>  
  9.         </property>  
  10.     </bean>  
  11.        
  12.     <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">  
  13.         <property name="transactionManager" ref="transactionManager"/>  
  14.         <property name="transactionAttributes">  
  15.             <props>  
  16.                 <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>  
  17.                 <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>  
  18.                 <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>  
  19.                 <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>  
  20.                 <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>  
  21.             </props>  
  22.         </property>  
  23.     </bean>    
  24.        
  25.     <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
  26.         <property name="beanNames">  
  27.             <value>*Service</value>  
  28.         </property>  
  29.         <property name="interceptorNames">  
  30.             <list>  
  31.                 <value>transactionInterceptor</value>  
  32.                 <value>hibernateInterceptor</value>    
  33.             </list>  
  34.         </property>  
  35.     </bean>    
  36.     <bean id="hibernateInterceptor"     
  37.         class="org.springframework.orm.hibernate3.HibernateInterceptor">     
  38.         <property name="sessionFactory" ref="sessionFactory" />     
  39.     </bean>  
  40.   
  41. </beans>  

 然后是spring方面的配置

  

xml 代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans  
  3.     xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  
  6.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  7.         <property name="sessionFactory">  
  8.             <ref bean="sessionFactory"/>  
  9.         </property>  
  10.     </bean>  
  11.        
  12.     <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">  
  13.         <property name="transactionManager" ref="transactionManager"/>  
  14.         <property name="transactionAttributes">  
  15.             <props>  
  16.                 <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>  
  17.                 <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>  
  18.                 <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>  
  19.                 <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>  
  20.                 <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>  
  21.             </props>  
  22.         </property>  
  23.     </bean>    
  24.        
  25.     <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  
  26.         <property name="beanNames">  
  27.             <value>*Service</value>  
  28.         </property>  
  29.         <property name="interceptorNames">  
  30.             <list>  
  31.                 <value>transactionInterceptor</value>  
  32.                 <value>hibernateInterceptor</value>    
  33.             </list>  
  34.         </property>  
  35.     </bean>    
  36.     <bean id="hibernateInterceptor"     
  37.         class="org.springframework.orm.hibernate3.HibernateInterceptor">     
  38.         <property name="sessionFactory" ref="sessionFactory" />     
  39.     </bean>  
  40.   
  41. </beans>  

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics