喜欢架构方面的东西,在一年多以前就开始接触freemarker,velocity,jsf,spring....,很遗憾现在才开始做这方面的整合。在网上很少看到jsf与模板技术同使用的例子,都说jsf速度不太理想,我想jsf与模块引擎结合一定会给我们带来惊喜。
下面介绍一下这方面的研究成果。
首先从web.xml开始吧!
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"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref bean="sessionFactory"/>
- </property>
- </bean>
- <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
- <property name="transactionManager" ref="transactionManager"/>
- <property name="transactionAttributes">
- <props>
- <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
- <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
- </props>
- </property>
- </bean>
- <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
- <property name="beanNames">
- <value>*Service</value>
- </property>
- <property name="interceptorNames">
- <list>
- <value>transactionInterceptor</value>
- <value>hibernateInterceptor</value>
- </list>
- </property>
- </bean>
- <bean id="hibernateInterceptor"
- class="org.springframework.orm.hibernate3.HibernateInterceptor">
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
- </beans>
然后是spring方面的配置
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"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref bean="sessionFactory"/>
- </property>
- </bean>
- <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
- <property name="transactionManager" ref="transactionManager"/>
- <property name="transactionAttributes">
- <props>
- <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
- <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
- <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
- </props>
- </property>
- </bean>
- <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
- <property name="beanNames">
- <value>*Service</value>
- </property>
- <property name="interceptorNames">
- <list>
- <value>transactionInterceptor</value>
- <value>hibernateInterceptor</value>
- </list>
- </property>
- </bean>
- <bean id="hibernateInterceptor"
- class="org.springframework.orm.hibernate3.HibernateInterceptor">
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
- </beans>