Struts 1之后,是Struts 1.x,Struts 2,Shale还是Nexus?

来源:互联网 发布:景别的作用 知乎 编辑:程序博客网 时间:2024/05/16 12:39
写在《Struts基础教程》(Beginning Apache Struts,除Pro Struts and Ajax之外最新出版的Struts图书)一书即将出版之际。

虽然面临许多开源框架的竞争,但Struts多年来始终是最为流行、用户群体最为庞大的Java Web MVC 框架。有很多评论说,Struts的整体架构已经过时了,未来是JSF这样基于组件的框架的。然后又传来了BeeHive、Spring和WebWork有意合作的消息,最后落实的,却是WebWork与Struts的合并。

为了回应挑战,Struts的主页上除了1.1,1.2,1.3之外,还先后出现过Action 1、Action 2、Jericho、Struts Classic、OverDrive、Nexus、Shale和Ti等等新鲜的名字。Struts 1.0之后到底是什么呢?

首先,Action 1、Action 2很快就被直接称为1和2了。而Jericho在实验设想阶段就胎死腹中。

Struts Classic只是Struts 1.3中7个组件的开发代号。

OverDrive(意为“加速档”)是Struts的一个子项目,但并不是Struts本身的延伸。它是一个跨平台的实验项目,目的是使用一组案例(类似于ASP.NET Starter Kit)驱动业务层框架的设计和开发。用Ted Husted的话说,Spring将附带的示例视为“一等公民”,而OverDrive中示例是唯一的一等公民。示例程序所共用的MVC框架只是手段而已。目前,OverDrive已经包含了两个示例——电话簿和邮件阅读器,用ASP.NET/Mono开发,但是Java 5和PHP 5版本也在计划中。

Nexus(意为“连杆”)是OverDrive所用的MVC框架,就是那个OverDrive的例子中隐藏了的“手段”。它又是在Ted开发的Jarkata Commons中Chain of Responsibility的.NET移植版Agility上构建的。

噢老天,终于到Shale(意为“页岩”)了。按Apache Struts网站的说法,“Shale是一个现代Web应用框架,本质上基于JSF。架构上Shale是一组松散耦合的服务,可以按需要进行组合,满足特定的应用需求。它还提供了许多附加功能,包括事件回调、含会话作用域状态的对话、称为Clay(意为“粘土”)的视图技术,基于注解(annotation)的功能(可减少配置需要),以及对远程处理的支持。Shale还提供了与其他框架的集成。”显然,Shale是一个另起炉灶的开发框架,目的就是为了支持JSF标准。因为在原有的Struts架构上,要在同时兼顾向后兼容性的前提下支持JSF是几乎不可能的。

好了,Ti呢?Ti是Titanium(意为“钛”)的简称,它才是真正的Struts 2的代号,而且现在已经被后者取代。Struts 2实际上是以WebWork为基础开发的。或者用Struts的官方说法,因为WebWord的特性中包含了大部分Struts路线图中计划,所以这是顺理成章的。它仍然维持了原来Struts基于Action的架构。

那么,你的下一个项目该用哪一种Struts呢?Struts 1.x,Struts 2,Shale还是Nexus?

首先,Struts 1.x并没有过时:
“No.

There is a robust and vibrant community of developers using Struts 1 in production, and we expect that thousands of teams will continue to base new projects on Struts 1, and continue to support existing projects, for many, many years to come.

New and improved extensions for Struts 1 continue to appear regularly. In 2006 alone, we've seen releases of Hoople, Strecks, JSP Control Tags, Sprout, Spring Web Flow, DWR, Calyxo, FormDef, and Java Web Parts. There are dozens of books and hundreds of articles available to help people get started with Struts 1 or improve the application they already have.

Since the merger, Struts 1 has gone on to release a new minor version, Struts 1.3, and new 1.x releases are being planned. Struts 1 continues to be the most popular and best supported web application framework for Java.

Of course, if you are starting a new project, and have your choice of frameworks, this might be a good time to consider whether you would like to continue to use Struts 1 or whether it's time to try Struts 2.”


Struts Roadmap FAQ是这么说的:

“首先,如果你是单独开发一个小程序,可能根本不需要框架。Simple applications can be written with JSF or JSP with JSTL "out of the box." (If you choose JSF, be sure to give Java Studio Creator a try.)

Multi-developer teams working on larger applications will probably find a MVC framework useful.

When choosing a framework, two key considerations are which user interface technology and which version of Java you would like to use. Popular user interface technologies include JavaServer Faces (JSF), conventional JavaServer Pages (JSP), and templating technologies like Velocity. Another popular UI technology to consider is AJAX.

(For more about the technologies underlying modern web applications, see the Key Technologies primer.)

While both Struts 1 and 2 support JSP, Velocity, and XSLT, Struts 2 has better support for JSF and first-class support for template engines like Velocity and FreeMarker, and, optionally, JasperReports.

Both versions work well with AJAX, but Struts 2 includes an AJAX theme that can give your interactive pages a boost. Under the name WebWork, Struts 2 already powers many large enterprise-grade solutions, including Atlassian's JIRA and Confluence applications.

On the JVM front, Struts 2 is targeted for Java 5, but provides backward compatibility for Java 4. Struts 1 is targeted for Java 4. (Struts 1 developers using Java 5 might want to consider Strecks, a set of Java 5 extensions for Struts 1.2.)

If you would like to use JSF exclusively, then Apache Shale might be a good choice. Originally a Struts subproject, Shale is now a top-level ASF project.”


 

链接:Lightbody访谈

原创粉丝点击