`

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 开发来说,起步是一件最困难的事情之一。对于巨大数量的开源技术来说,决定选择哪些技术可能是很困难的 实际上,对于他们的上手可能更加困难。假设你选择了 Struts Hibernate, 那么你如何去在一起使用他们。即使你去查找 Hibernate 主站或者 Struts 主站,你仍然难以找到关于如何整合两者的信息。假如你又再打算整合 Spring 又会如何?作为一个开发者,我认为最好的学习方法是浏览简单的示例程序和指南来解释如何扩展这些程序。为了我能够学习和记住如何集成像 Hibernate, Spring, Struts, Ant/XDoclet 这样的开源技术,我编写了 AppFuse AppFuse 的诱人之处就是你能够即刻开始使用 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 安全。

注:在 2003 3 月, 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 以后,我刨除了其中和具体相关的东西使它重新成为一般的入门程序,正如我开始设想的那样。它花费了我几乎三个月的时间,但是最终我在 2003 4 月发布了 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 代码是非常枯燥乏味的,而当更新表字段的时候修改 sql VOs 的代码是一件更枯燥的事情。为了解决这些问题,我选择使用 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.

2004 4 月,我将 AppFuse 项目从 SourceForge Struts project 移到了 java.net 。我这样作有几个原因。首先是 AppFuse SourceForge 的一个子项目,它的用户基础增长的非常快,需要专门的邮件列表和论坛。第二是因为 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).

分享到:
评论

相关推荐

    AppFuse学习笔记(J2EE入门级框架)

    用户在构建 Web 层时可以从 Struts、Spring MVC、Webwork、Taperstry 或 JSF 中选择适合的 Web 框架。AppFuse 还鼓励使用测试驱动开发(TDD),通过 JUnit 对各个层次进行测试,确保代码质量,甚至可以测试 JSP 页面...

    使用 AppFuse 快速构建 J2EE 应用

    在实际使用中,你可以按照以下步骤使用 AppFuse: 1. **选择模板**:根据你的项目需求,从 AppFuse 提供的多种模板中挑选适合的类型。 2. **生成项目**:使用 Maven 的 archetype:generate 命令,输入相应的 ...

    使用AppFuse快速构建J2EE应用.doc

    AppFuse 是一个开源项目,旨在帮助开发者快速构建J2EE应用程序。它提供了一种模板化的方法,通过结合现有的最佳实践和流行的技术栈,如Spring、Hibernate和Tapestry,简化了开发过程。本文将深入探讨如何利用AppFuse...

    AppFuse

    ### AppFuse:加速J2EE项目开发 #### 一、简介与背景 AppFuse是一个用于启动J2EE项目的工具包,它提供了一种快速而简便的方法来构建基于Java的应用程序。该工具包由Matt Raible创建,他在网络开发领域拥有丰富的...

    AppFuse1.x快速构建J2ee应用

    在 AppFuse 1.x 版本中,开发者可以快速地搭建起一个基本的 MVC(Model-View-Controller)架构的 Web 应用,同时支持多种框架,如 Struts、Spring MVC 和 Tapestry。 ### 1. AppFuse 概览 AppFuse 提供了一个基础...

    appfuse_quick_start

    AppFuse 是一个开源项目,它的主要目标是提供一个...总之,"appfuse_quick_start"是一个引导你快速上手AppFuse的资源,通过学习和实践,你可以迅速掌握基于AppFuse的Web应用开发,从而提高开发效率,降低项目的复杂性。

    appfuse

    AppFuse 是一个开源项目,旨在简化Java Web应用程序的开发过程。它提供了一个基础框架,集成了许多流行的开源库,如Spring、Hibernate、Struts或Spring Boot等,帮助开发者快速搭建应用骨架。AppFuse 可以根据选定的...

    appfuse开放web service指南

    appfuse开放web service指南 appfuse开放web service指南

    appfuse学习笔记(一)安装部署

    AppFuse 是一个开源项目,它提供了一种快速构建企业级 Web 应用程序的方式。它使用了多种流行的技术栈,如 Spring Boot、Hibernate、Thymeleaf 和 Maven,使得开发者可以更高效地开发基于 Java 的 Web 应用。在本文...

    AppFuse项目研究

    AppFuse 是一个由 Matt Raible 创建的开源项目,旨在为初学者提供一个快速入门的 J2EE 框架模板。它集成了多种流行的技术,包括 Spring、Hibernate、iBatis、Struts、Xdoclet 和 JUnit,同时也支持 Taperstry 和 JSF...

    可直接使用的appfuse项目

    AppFuse是一个集成了众多当前最流行开源框架与工具(包括Hibernate、ibatis、Struts、Spring、DBUnit、Maven、Log4J、Struts Menu、Xdoclet、SiteMesh、OSCache、JUnit、JSTL等(现在还有lucene的,无敌了))于一身的...

    appfuse2学习日记

    5. **下载源代码**:在项目目录中运行 `mvn appfuse:full-source` 命令。 6. **运行项目**: - 使用 Jetty 运行项目:`mvn jetty:run-war`。 - Jetty 下载地址:...

    AppFuse Primer

    - 书中提供了大量的示例代码和实用指南,旨在帮助读者深入了解AppFuse的工作原理并学习如何使用它来构建高质量的Web应用程序。 #### 三、AppFuse Primer的主要内容概述 - **基础知识**: 在开始使用AppFuse之前,...

    建立项目原型骨架的步骤(最新版本appfuse)appfuse2.1.0-M2

    2. 生成项目后,使用`mvn appfuse:full-source`命令初始化项目。这个命令会处理ant存在的问题,特别是Windows环境下遇到的问题,确保$USER_HOME/.m2/repository目录存在并包含正确的settings.xml文件。 3. 接下来,...

    appfuse-documentation-2.1.0官方文档

    AppFuse 是一个集成了一系列流行的开源框架和技术的 Web 开发框架,旨在帮助 J2EE 开发者更高效地构建 Web 应用程序。它包含了诸如 Hibernate、ibatis、Struts、Spring、DBUnit、Ant、Log4J、Struts Menu、Xdoclet、...

Global site tag (gtag.js) - Google Analytics