Topic: Jute Forum and Spring Framework

  Print this page

1.Jute Forum and Spring Framework Copy to clipboard
Posted by: rainman
Posted on: 2004-10-15 01:53

现在已经将Jute Froum 1.4 的一个分支移植到Spring Framework中了. 只用了一个小时, 显示了良好的移植性啊, 吼吼.

2.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: rainman
Posted on: 2004-10-15 01:56


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

  <!-- ===========================================================-->
  <!-- Velocity configurer. -->
  <!-- ===========================================================-->
  <!--
   This bean sets up the Velocity environment for us based on a root path for templates.
   Optionally, a properties file can be specified for more control over the Velocity
   environment, but the defaults are pretty sane for file based template loading.
  -->
  <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer" singleton="true">
   <property name="configLocation"><value>/WEB-INF/conf/velocity.properties</value></property>  
   <property name="resourceLoaderPath"><value>/WEB-INF/templates/</value></property>
    <property name="velocityProperties">
     <props>
     <prop key="resource.loader">file</prop>
     <prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.FileResourceLoader</prop>
     <prop key="file.resource.loader.path">${webapp.root}/WEB-INF/templates</prop>
     <prop key="file.resource.loader.cache">true</prop>
     <prop key="file.resource.loader.modificationCheckInterval">2</prop>
     <prop key="velocimacro.library">macro_forum.vm</prop>
     </props>
    </property>  
  </bean>
  
  <!-- ===========================================================-->
  <!-- View resolver. Required by web framework. -->
  <!-- ===========================================================-->
  <!--
   View resolvers can also be configured with ResourceBundles or XML files. If you need
   different view resolving based on Locale, you have to use the resource bundle resolver.
  -->
  <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
   <property name="cache"><value>true</value></property>
   <property name="prefix"><value>/</value></property>
   <property name="suffix"><value>.vm</value></property>
   <property name="contentType"><value>text/html; charset=ISO-8859-1</value></property>
   <property name="exposeSpringMacroHelpers"><value>true</value></property>
  </bean>
      
  <bean id="forumUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="interceptors">
      <list>                
      </list>
    </property>
    <property name="mappings">
      <props>        
        <prop key="*">forumController</prop>        
      </props>
    </property>
  </bean>
  
  <bean id="forumController" class="org.jute.forum.ForumController">
     <property name="handlerNameResolver"><ref bean="forumControllerResolver"/></property>
  </bean>
  
  <bean id="forumControllerResolver" class="org.jute.framework.spring.MapHandlerNameResolver">
    <property name="mappings">
      <map>
        <entry key="/index"><bean class="org.jute.forum.Homepage"/></entry>
        <entry key="/page/*"><bean class="org.jute.forum.resource.ResourceAction"/></entry>
        <entry key="/post/delete"><bean class="org.jute.forum.post.DeletePost"/></entry>
        <entry key="/post/edit"><bean class="org.jute.forum.post.EditPost"/></entry>
        <entry key="/post/forward"><bean class="org.jute.forum.post.ForwardPost"/></entry>
        <entry key="/post/new"><bean class="org.jute.forum.post.NewPost"/></entry>
        <entry key="/post/page"><bean class="org.jute.forum.post.PostPage"/></entry>
        <entry key="/post/preview"><bean class="org.jute.forum.post.PreviewPost"/></entry>
        <entry key="/post/print"><bean class="org.jute.forum.post.PrintPost"/></entry>
        <entry key="/post/reply"><bean class="org.jute.forum.post.ReplyPost"/></entry>
        <entry key="/post/view"><bean class="org.jute.forum.post.ViewPost"/></entry>
        <entry key="/user/download/*"><bean class="org.jute.forum.user.DownloadFile"/></entry>
        <entry key="/user/edit"><bean class="org.jute.forum.user.EditUser"/></entry>
        <entry key="/user/help"><bean class="org.jute.forum.user.UserHelp"/></entry>
        <entry key="/user/info"><bean class="org.jute.forum.user.UserInfo"/></entry>
        <entry key="/user/list"><bean class="org.jute.forum.user.UserList"/></entry>
        <entry key="/user/login"><bean class="org.jute.forum.user.UserLogin"/></entry>
        <entry key="/user/logout"><bean class="org.jute.forum.user.UserLogout"/></entry>
        <entry key="/user/markread"><bean class="org.jute.forum.user.UserMarkRead"/></entry>
        <entry key="/user/myforum"><bean class="org.jute.forum.user.MyForum"/></entry>
        <entry key="/user/message"><bean class="org.jute.forum.message.MessageAction"/></entry>
        <entry key="/user/online"><bean class="org.jute.forum.user.UserOnline"/></entry>
        <entry key="/user/register"><bean class="org.jute.forum.user.UserRegister"/></entry>
        <entry key="/user/survey"><bean class="org.jute.forum.survey.SurveyAction"/></entry>
        <entry key="/user/whatsnew"><bean class="org.jute.forum.user.WhatsNew"/></entry>
      </map>
    </property>
  </bean>
  
</beans>


有熟悉Sping的同好吗? 来探讨一下配置Spring的issue.

3.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: floater
Posted on: 2004-10-18 09:12

Here are some points I could think of:

move user checking to an interceptor.

not sure how to handle validation in your case(using one controller)

i18n messages to isolated files.

themes

Did you benefit from this migration?

4.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: rainman
Posted on: 2004-10-23 06:29

Agree to move user checking into an interceptor, acutally I did that already.
It's easy for other people to implement their own user authentication.

Jute forum already implement data binding, so data validation is an easy part in this case.

i18n messages and theme are also supported by Jute itself(using xml resource loader). Properties based messages sometimes is not convenient for editiing.

The benefit I got:
1. IOC best practice
2. More and more loose coupling
3. Tested hibernate O/R mapping tool with spring.

The issue I found:
Hibernate lazy-init is a good idea, but open-session-in-view mode is not so good. Spring's solution is not good at this point.

Thanks floater, for your comments.

5.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: floater
Posted on: 2004-10-23 10:08

you are welcome.

yes, we have several different implementations for user authentications so we could run applications in different environments(using different config files), quite convenient.

I found the testing is more easier than before, I can even test controllers now, without servlet containers.

I am using ibatis in production, no production experience on Hibernate. It seems there is a fundamental difference between Spring underlying logic and the open-session-in-view mode, even Raible(Spring live author) didn't do it right at the first place.

In Spring 1.1.1, there are a few testing classes in the test dir that are nice. The neat idea is that we run all the testing in one transaction and roll it back at the end so we don't need to clean up dbs. Now the issue is how to set the dbs to a known state and how to test db code. I tend to put the code to populate dbs and the code to verifiy output in the same class, rather than spread them around, e.g., in an ANT script, xml files, etc. This is a better choice if we need to modify these data, ever.

Another interesting experience is that once I started using Spring, it's really hard to go back to the old way, Smile. I just finished a small, but nasty project with 3 implementations of a DAO layer, a pure jdbc one, a spring jdbc one, and a spring + ibatis one. It's just so hard, like fighting against something, to do it in pure jdbc.

6.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: yikid
Posted on: 2004-11-07 20:57

spring+velocity是如何支持国际化的资源文件的?
jsp可以使用spring的标签。vm怎么做的?

7.Re:Jute Forum and Spring Framework [Re: rainman] Copy to clipboard
Posted by: simonli
Posted on: 2004-11-27 14:45

不错


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923