What is 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 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).

One of the best parts, in my opinion, is that it embraces the Java community's ideas and suggestions. The directory structure and build file are largely based on Erik Hatcher and Steve Loughran's excellent Java Development with Ant book. In this book, Erik built a sample application that inspired me to learn more about Ant and XDoclet -- and use it in my Struts development.

When I first started learning and using Hibernate in AppFuse, I made many mistakes -- and the community let me know. At first, I opened and closed its Session object for each DAO method. When Gavin told me this was a bad idea, I made modifications to use an OpenSessionInView pattern, with my own ServletFilter to do the work. I passed the session object into each method signature, for which the community repeatedly questioned my logic. My answer was, "I wanted to get it working more than anything -- do you have a better idea?" The better idea turned out to be using the Session as a constructor argument, which worked pretty well.

Then, late last year, I discovered the Spring framework and found the beautiful solution I'd been looking for. Using its ORM support, I was able to eliminate any Session handling in AppFuse; now Spring elegantly handles it all. AppFuse now uses Spring's OpenSessionInViewFilter. All I needed to do was configure it in web.xml and it manages opening and closing the session for me. When I integrated Spring in AppFuse's persistence layer, I deleted two or three classes and reduced my LOC count by around 75 percent. All of the Hibernate issues I'd had before disappeared! In addition, I was quickly able to add a DAO implementation using iBATIS, which I worked with on a project last year. On that project, I discovered that iBATIS was easy to use and worked very well for interacting with complex database schemas.

AppFuse is not only a jumpstart kit for your web apps; it's also a showcase for integrating technologies like Hibernate, Spring, and Struts. Tutorials exist for integrating these different open source components, but rarely do they give you an application you can walk away with and use to develop your next application. In a sense, AppFuse is a glue that binds open source projects together. When I found Spring, it was a perfect fit, since it was the glue to configure components and loosely couple the different layers of an application. Erik's book might have been the match that lit AppFuse, but Spring is the gasoline that really got it roaring. Spring has vastly simplified how I develop with AppFuse and forced me to follow best practices in J2EE. In short, it's the best tool I've ever used with J2EE. I realize Spring is not the be-all-end-all for J2EE applications -- AppFuse worked fine before I integrated it. However, it helped answer all of my "How should I do ..." questions -- which was a nice relief.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值