AppFuse: Start Your J2EE Web Apps (中英文对照)

1  AppFuse: 开始你的 J2EE web 应用

by Matt Raible
<chsdate w:st="on" year="2004" month="7" day="15" islunardate="False" isrocdate="False">07/15/2004</chsdate>


<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <stroke joinstyle="miter"> <formulas> <f eqn="if lineDrawn pixelLineWidth 0"> <f eqn="sum @0 1 0"> <f eqn="sum 0 0 @1"> <f eqn="prod @2 1 2"> <f eqn="prod @3 21600 pixelWidth"> <f eqn="prod @3 21600 pixelHeight"> <f eqn="sum @0 0 1"> <f eqn="prod @6 1 2"> <f eqn="prod @7 21600 pixelWidth"> <f eqn="sum @8 21600 0"> <f eqn="prod @7 21600 pixelHeight"> <f eqn="sum @10 21600 0"> </formulas> <lock v:ext="edit" aspectratio="t"> </shapetype> <shape id="_x0000_i1025" style="WIDTH: 7.5pt; HEIGHT: 0.75pt" type="#_x0000_t75" alt=""> <imagedata src="file:///C:\DOCUME~1\lesky\LOCALS~1\Temp\msohtml1\01\clip_image001.png" o:href="http://today.java.net/im/a.gif"> </shape>

<shape id="_x0000_i1026" style="WIDTH: 7.5pt; HEIGHT: 0.75pt" type="#_x0000_t75" alt=""> <imagedata src="file:///C:\DOCUME~1\lesky\LOCALS~1\Temp\msohtml1\01\clip_image001.png" o:href="http://today.java.net/im/a.gif"> </shape>

 

 

 

 

 

<shape id="_x0000_i1027" style="WIDTH: 7.5pt; HEIGHT: 0.75pt" type="#_x0000_t75" alt=""> <imagedata src="file:///C:\DOCUME~1\lesky\LOCALS~1\Temp\msohtml1\01\clip_image001.png" o:href="http://today.java.net/im/a.gif"> </shape>

One of the hardest parts about J2EE development is getting started. There is an immense amount of open source tools for web app development. Making a decision on which technologies to use can be tough -- actually beginning to use them can be even more difficult. Once you've decided to use Struts and Hibernate, how do you go about implementing them? If you look on the Hibernate site or the Struts site, you'll probably have a hard time finding any information on integrating the two. What if you want to throw Spring into the mix? As a developer, the best way for me to learn is by viewing sample apps and tutorials that explain how to extend those applications. In order for me to learn (and remember) how to integrate open source technologies such as Hibernate, Spring, Struts, and Ant/XDoclet, I created AppFuse. The beauty of AppFuse is you can actually get started with Hibernate, Spring, and Struts without even knowing much about them. Using test-driven development, AppFuse and its tutorials will show you how to develop a J2EE web application quickly and efficiently.

J2EE 开发来说,起步是一件最困难的事情之一。对于巨大数量的开源技术来说,决定选择哪些技术可能是很困难的 实际上,对于他们的上手可能更加困难。假设你选择了 StrutsHibernate, 那么你如何去在一起使用他们。即使你去查找 Hibernate 主站或者 Struts 主站,你仍然难以找到关于如何整合两者的信息。假如你又再打算整合 Spring 又会如何?作为一个开发者,我认为最好的学习方法是浏览简单的示例程序和指南来解释如何扩展这些程序。为了我能够学习和记住如何集成像 Hibernate, Spring, Struts, Ant/XDoclet 这样的开源技术,我编写了 AppFuseAppFuse 的诱人之处就是你能够即刻开始使用 Hibernate, Spring, and Struts 却无需知道很多关于它们的知识。 AppFuse 和它的指南将告诉你如何快速有效的使用测试驱动方式开发一个 J2EE web 应用程序。

 

2          The Birth of AppFuse

Appfuse 的诞生

In early 2002, I managed to land a contract where I was the lone developer. I was responsible for everything, from gathering requirements to database creation to DHTML on the web front end. While I'd done a lot of front-end work (Struts, HTML, etc.) over the years, the business layer and persistence layer were mostly new to me. So I searched and searched for J2EE patterns to do things the "right way" for my new client. I ended up implementing Business Delegates, DAOs, and ServiceLocators -- many of them modeled after J2EE Blueprints. Towards the end of that contract, I was contracted to help write a book on JSP 2.0. The publisher was Wrox Press and the book was Professional JSP 2.0. I volunteered to write two chapters -- one on Struts and one on web security. Note: in March 2003, Wrox went out of business and this book eventually became Pro JSP, Third Edition, published by Apress.
2002 年初的时候,我得到了一份个人独立开发的合同,我要负责所有的事情,包括从收集需求到数据库创建和编写 web 前端的 DHTML 。虽然我做过多年前台的工作 (Struts, HTML, 等等 ) ,但是业务层和数据持久层的很多东西对我来说是不熟悉的。于是我不断的查找各种 J2EE 模式来以“正确的方法”满足我的新客户。我最终实现了 Business Delegates, DAOs, and ServiceLocators – 很多 J2EE Blueprints 中的模型。在那个合同的最后,我被约定去帮助写一本关于 JSP2.0 的书。出版商是 Wrox Press ,这本书的名字是 Professional JSP 2.0 我志愿编写了两章――一章是关于 Struts 而另一章是关于 web 安全。

注:在 20033 月, Wrox 停业,最终该书 由 Apress 出版,名为: Pro JSP, Third Edition

When you write a technical book, it's helpful to use a sample app to demonstrate concepts. I was tired of reading books that had a throwaway sample app, so I wanted to develop something meaningful; something I could use after I was done writing. My initial thoughts were to write an application that would help you get started with Struts, and would use XDoclet to do a lot of the heavy lifting. It also had to have a lot of security features so I could use it for my chapter on web application security. I came up with the name struts-xdoclet and began developing my application.

在你编写一本技术类书籍时,使用一个简单的应用去示范一些概念是非常有效的。我对很多提供的示例程序是看后即弃的书是非常反感的,于是我决定去开发一些能够用的更久一些的程序,一些东西是我能够在我结束写作以后仍然可以使用的。我最初的想法是编写一个能够帮助你开始 struts 并利用 XDoclet 去做很多繁琐工作的应用程序。它的许多安全特性也能够用在我的“ web 应用安全性”章节中。我给它取名叫做 struts-xdoclet 并且开始编写这个程序。

After a couple of weeks, I decided that " struts-xdoclet " was too hard to say and renamed the project AppFuse. I developed the sample app for my Struts chapter using AppFuse and released it as Struts Resume. After publishing Struts Resume, I needed to extract the resume-specific stuff out of it to revert back to the generic "jumpstart" application I wanted AppFuse to be. It took me almost three months, but I finally released the first official version of AppFuse in April 2003.

过了几周以后,我认为 " struts-xdoclet " 这个名字很拗口,于是把项目改名为 AppFuse 。我为我的 Struts 章节生成了一个简单的应用并把它作为 Struts Resume 发布出去。在发布了 Struts Resume 以后,我刨除了其中和具体相关的东西使它重新成为一般的入门程序,正如我开始设想的那样。它花费了我几乎三个月的时间,但是最终我在 20034 月发布了 AppFuse 的第一个正式版本。

Since its initial release, AppFuse has gone through many changes and improvements. Most of the technology decisions were made from experience. It was a pain to keep my ValueObjects (VOs) and ActionForms in sync, so ActionsForms are generated using XDoclet. I found it tedious to write JDBC and more tedious to update SQL and VOs when adding new table columns. To solve this, I chose to use Hibernate for persistence and use Ant/XDoclet to dynamically create my database tables. Rather than lose my tables' data each time, I integrated DBUnit, which also came in handy when running unit tests. I decided to use Tomcat/MySQL as the default server/database setup because I was most familiar with them. I integrated a plethora of unit/integration tests so I could make sweeping changes and verify that everything still worked (including the JSPs) by running ant test-all .

自从它的第一个发布版本以来, AppFuse 已经经历了许多改变和发展。大多数的技术选择是凭经验得出的。保持 ValueObjects (VOs)ActionForms 同步是一件很痛苦的事情,于是我使用了 XDoclet 来生成 ActionsForms 。我发现编写 jsbc 代码是非常枯燥乏味的,而当更新表字段的时候修改 sqlVOs 的代码是一件更枯燥的事情。为了解决这些问题,我选择使用 Hibernate 作为数据持久层并且使用了 Ant/XDoclet 来动态创建我的数据库的表。 Rather than lose my tables' data each time, 我集成了 DBUnit, which also came in handy when running unit tests. 使用 Tomcat/MySQL 作为默认的服务器和数据库是因为我最熟悉它们。我集成了所有的测试这样我能够在做出了大量改变以后运行 ant test-all 就 可以检查一切是否仍然可以正常工作(包括 JSP

In March of 2004, I moved the AppFuse project from the Struts project on SourceForge to java.net. I had a couple of reasons for doing this. First of all, it was a sub-project on SourceForge, and its user base was growing quickly. It needed dedicated mailing lists and forums. Secondly, java.net seemed to do a better job of marketing projects and I'd heard their CVS system was much more stable. My experience at java.net has been quite nice: it's a very stable system, and the administrators are very supportive of the project and have even helped with marketing it.

20044 月,我将 AppFuse 项目从 SourceForge Struts project 移到了 java.net 。我这样作有几个原因。首先是 AppFuseSourceForge 的一个子项目,它的用户基础增长的非常快,需要专门的邮件列表和论坛。第二是因为 java.net 看起来提供了更好的销售项目的工作而且我听说他们的 CVS 系统非常的稳定。我在 java.net 的经历非常的美好:他是一个非常稳定的系统。而且管理员对项目的维护和支持非常的有效。

3          What is AppFuse?

AppFuse 是什么?

So after all that history, what is AppFuse? At its very core, AppFuse is a web application that you can package into a .war and deploy to a J2EE 1.3-compliant app server. It's designed to help you create new web applications using a new target in its build.xml file. The new target allows you to specify a name for your project and a name for the database it will talk to. Once you've created a project, you can instantly create a MySQL database and deploy it to Tomcat using ant setup . Furthermore, you can verify that the basic functionality of your new application works by running ant test-all . At this point, you might sneer and say, "What's the big deal? Anyone can create a .war file and deploy it to Tomcat." I agree, but do you have a setup-tomcat target that will configure Tomcat with JNDI resources for connections pooling and mail services? Most of what AppFuse does is not rocket science. In reality, it's nothing more than a directory structure, a build file, and a bunch of base classes -- with a few features thrown in. However, it has vastly accelerated my ability to start projects and develop high-quality, well-tested web applications.

AppFuse 究竟是什么? AppFuse 是一个你可以打包位一个 war 文件并可以在兼容 J2EE 1.3 的应用服务器中运行的 web 应用程序。它被设计成能够利用 build.xml new target 帮助你建立新的的 web 应用程序。 new target 允许你指定你的项目名称和数据库名称。一旦你建立了一个项目后,你可以利用 ant setup 创建 MySQL 数据库并发布程序到 Tomcat 。而且你可以执行 ant test-all 来 测试新工程的基本功能。这时,你可能会嘲笑说,“这有什么的,任何人都可以创建一个 .war 文件并发布到 tomcat”. 我同意这点,但是你有 setup-tomcat target 可以用来配置 Tomcat 的连接池的 JNDI 资源和 mail services? 事实上, AppFuse 并不是什么突破性的发明,它只是由一个目录结构,一个 build 文件,一堆基类等组成,然而,它能够让我能够快速构建可以高质量开发,易于测试的 web 应用程序。

AppFuse tries to make it as simple as possible to build, test, and deploy your application. It virtually eliminates setup and configuration, which are often the hard parts. Tools like Ant, JUnit, XDoclet, Hibernate, and Spring can be difficult to get started with. Furthermore, features like authentication, password hints, "remember me," user registration, and user management are things that most web apps need. AppFuse ships with tutorials for developing DAOs, business delegates, Struts actions (or Spring controllers), integrating tiles and validation, and uses an Ant-based XDoclet task (written by Erik Hatcher) to generate master/detail JSPs from model objects. It uses slick open source tag libraries like Struts Menu (for navigation) and the Display Tag (for paging and sorting lists).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值