Turbine 框架介绍

Jakarta Turbine 可能大家不是非常熟悉,但是它是一个很好的Web Framework(也有缺点,在以后为大家指出),先介绍一下 Turbine 的整体结构吧。 
Turbine 的开发包叫:TDK(Turbine Developer Kit),它有一组Jakarta Turbine子项目组成(Turbine 项目的子项目数仅次于 Jakarta Common 项目位于第二位),列举如下: 
1.Turbine:核心框架 
2.Torque:JDO 的Turbine实现,利用XML技术将关系性数据库和Java Class OO 映射,足以让你耳目一新。 
3.Fulcrum:服务框架,提供了大量的Web系统服务功能,个人认为Intake Service,Cache Service很棒。 
4.Maven:Java 项目更新工具,基于POM(project object model)概念,目前只支持Turbine。 
5.JCS(Java Caching System):是服务器段Java程序的分布式缓存系统,极棒的概念。 
6.Stratum:Turbine 和 Avalon 的移植工具。 
还有一个和 Turbine 轻密如战友的 Web 模版项目 Jakarta Velocity. 

1.Turbine 的历史: 

我用Turbine的时候是 2001年1月(很早吧),当时的 TDK 版本是1.1.A13,非常的不稳定,并且有相当多的 Bug.当时促使我们用Turbine的原因是其良好的MVC架构.当时EJB还根本没有火起来,Struts也只是一个雏形而已,而当时的Turbine已经发展的不错了(当然还有很多的问题). 
我当时选择了Turbine来开发一套物流管理系统,遇到的最大的困难是帮助文档奇缺,这是Microsoft的开发组件远远胜于当时的Java的一点(注1). 
但是我觉得当时的Turbine News Group的氛围非常的好,基本上问题都能得到解决,而且Turbine的升级速度要比现在快的多(我觉的最近的Turbine组有点懒,TDK(Turbine)3.0 Released 版本都快等了一年了,我的天).虽然文档很缺(注2),但是有这个新闻组的帮助,项目做的还比较顺利,一个附带的好处是让我习惯了看E文文档. 
Turbine 的发起人之一是Brett McLaughlin,我比较崇敬的程序员之一(我顶礼膜拜的是伟大的Anders).Turbine的开发宗旨是:"Turbine is a servlet based framework that allows experienced Java developers to quickly build secure web applications."(Turbine 提供给有经验的Java开发者一个快速开发安全Web应用的Servlet平台),我深有感触的觉得的确如此. 
日志: 
2000/9 Turbine 诞生了 
2001/3 Turbine 1.1 Released 
2001/6 Turbine 2.1 Released 
2002/12 Turbine 2.2 Released 
期待 3.0 

2.一些看法 

我现在在做 EJB + Struts 的开发,结合现在的经验谈谈我作为第一线的软件设计开发人员的想法. 
EJB 吸引大家的是它的标准中的容器(Container),组件(Component),分布式概念.我说一句实话,EJB 真的只适合于做大项目(ERP,SCM,CRM 等等),如果你只是做一个 Web Application(1000个人使用,提供100个动态页面的话)真的没必要自己给自己找麻烦. 
EJB 和数据层的结合用的是 CMP (EJB 2.0 & 2.1 建议尽量使用CMP来取代BMP以提高性能),但是你要用EJB进行抽象、多态是在是太困难了.IBM DeveloperWorks 上的一句话是我感同身受:"CMP 是开发针对于意志薄弱的开发者来说是不适合的". 
而 Turbine 的 Torque OM 机制使得你能充分发挥你的想象力和创造力,我一直认为计算机语言有好坏之分,标准就是它是否能使你的想象得到实现并且十分漂亮.Turbine Framework 对于开发者来说是十分优秀的. 
(注3) 

3.TDK 的相关技术 

Ant:Turbine 项目的编译技术使用的都是Ant.熟悉Ant至关重要.TDK 的核心编译文件是..\webapps\yourproject\WEB-INF\build\build.xml 和 build.properties.熟悉Ant的人一看,拷,太熟悉了!!! 

Log4j:Turbine 项目的日志纪录用的是 Jakarta 组的Log4j. 
--------------------------------------------------------------------------------- 
# ------------------------------------------------------------------- 

# L O G G I N G 

# ------------------------------------------------------------------- 
# We use Log4J for all Turbine logging and we embed the log4j 
# properties within our application configuration. 

# NOTE: 
# The presence of ${webapp} in the logging configuration 
# is not a mistake. Internally the value of ${webapp} 
# is set so that you can use it with standard log4j 
# properties to get logs to appear in your 
# webapp space. 
# ------------------------------------------------------------------- 
log4j.category.default = INFO, default 
log4j.appender.default = org.apache.log4j.FileAppender 
log4j.appender.default.file = ${webapp}/logs/turbine.log 
log4j.appender.default.layout = org.apache.log4j.PatternLayout 
log4j.appender.default.layout.conversionPattern = %d [%t] %-5p %c - %m%n 
log4j.appender.default.append = false 

log4j.category.sql = DEBUG, sql 
log4j.appender.sql = org.apache.log4j.FileAppender 
log4j.appender.sql.file = ${webapp}/logs/sql.log 
log4j.appender.sql.layout = org.apache.log4j.PatternLayout 
log4j.appender.sql.layout.conversionPattern = %d [%t] %-5p %c - %m%n 
log4j.appender.sql.append = false 

log4j.category.vdebug = DEBUG, vdebug 
log4j.appender.vdebug = org.apache.log4j.FileAppender 
log4j.appender.vdebug.file = ${webapp}/logs/vlog.log 
log4j.appender.vdebug.layout = org.apache.log4j.PatternLayout 
log4j.appender.vdebug.layout.conversionPattern = %d [%t] %-5p %c - %m%n 
log4j.appender.vdebug.append = false 
--------------------------------------------------------------------------------- 
以上的配置是位于../WEB-INF/conf/下的TurbineResources.properties文件中,看看文件名就知道他有多重要了,我会在以后的文章中详细介绍这个文件的.:-) 

Velocity:Jakarta 项目组极棒的模版项目,它的配置信息也在TurbineResources.properties中 
--------------------------------------------------------------------------------- 
# ------------------------------------------------------------------- 

# V E L O C I T Y S E R V I C E 

# ------------------------------------------------------------------- 

# The location of Velocity configuration file, relative to webapp root 
# These properties will override the default properties set by Velocity. 
# You should specify the path to the templates directories as well as 
# the path to the log file and they should also be relative to webapp root 

services.VelocityService.template.extension=vm 
services.VelocityService.default.page.template = /Default.vm 
services.VelocityService.default.layout.template = /Default.vm 
services.VelocityService.runtime.log=/logs/velocity.log 
# 注意定义为中文 GB2312 
services.VelocityService.input.encoding=GB2312 
services.VelocityService.velocimacro.library = GlobalMacros.vm 
services.VelocityService.resource.loader = file 
services.VelocityService.file.resource.loader.deSCRIPTion = Velocity File Resource Loader 
services.VelocityService.file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader 
services.VelocityService.file.resource.loader.path = /templates 
services.VelocityService.file.resource.loader.cache = false 
services.VelocityService.file.resource.loader.modificationCheckInterval = 2 
services.VelocityService.resource.loader = classpath 
services.VelocityService.classpath.resource.loader.deSCRIPTion = Velocity Classpath Resource Loader 
services.VelocityService.classpath.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader 

services.VelocityService.earlyInit = true 
--------------------------------------------------------------------------------- 
Velocity 使用的详细介绍可参看我转贴的<>,这篇文章我很早就收集了,实在忘了是那位高人之作(如果是你,请指正,我也真的感谢你的文章对我的帮助). 

4.结束语 

这篇文章是我随性写的,看官如果有任何意见的话写信给我:[email protected],绝对虚心接受. 

注: 
1.在Java开发之前,我用的是Microsoft Visual Studio 5.0 - 6.0,一个遗留问题是当时写Turbine时的版本控制软件选择的还是SourceSafe 6.0.:-). 
2.目前为止,我还没有看见过介绍Jakarta组项目的中文书籍,除了一本Velocity的使用手册,我大致看了一看,基本上属于翻译Velocity的Help文档,价值不是很高,没有涉及到Velocity的源代码分析和实现. 
3.关于 EJB 和 Trubine 技术的比较我会在以后写专题的

猜你喜欢

转载自zfei.iteye.com/blog/1275246