Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Develop enterprise Java applications with <em>POJOs in Action</em>

Avoid the problems associated with EJB by working with plain-old Java objects and lightweight frameworks

Chris Richardson has been developing enterprise Java applications for several years. In the beginning, he based these applications on servlets, JavaServer Pages, and Enterprise JavaBeans (EJB). Chris discovered that he could simplify development by using plain-old Java objects—POJOs. Although using POJOs made it possible to test code without having to wait for this code to deploy to a server (a significant source of frustration), the lack of POJO support by the servlet and EJB frameworks required Chris to "jump through a few hoops to use them." After describing some of these hoops in an article, Chris learned of lightweight frameworks that use POJOs directly.

Readers told Chris to forget about using entity beans to manage an application's persistence—frameworks that map objects to relational database tables are simpler. It did not take long for Chris to start working with two persistence technologies: JDO (Java Data Objects) and Hibernate. Now that the troublesome entity beans could be eliminated, there was still the matter of dealing with the problematic session beans. As with entity beans, session beans need to be deployed to the server, and that slows development. After reading a few articles on the Spring framework, Chris found a solution to the session bean problem.

Working with POJOs in the context of the lightweight JDO, Hibernate, and Spring frameworks let Chris experience enterprise Java development with much less frustration than when he worked with the Java EE EJB framework (Java Platform, Enterprise Edition, or Java EE, is Sun's new name for J2EE). He decided to write a book that shares his POJO/lightweight framework knowledge, and teaches simpler and faster ways to write enterprise Java applications. The result POJOs in Action, published by Manning Publications in January 2006, focuses on pure POJO and lightweight framework design, a much better approach for many Java enterprise applications. In this article, I present my review of POJOs in Action.

POJOs in Action

POJOs in Action targets developers and architects experienced in developing enterprise Java applications in the context of Java EE's EJB framework, and wanting to effectively use POJOs and lightweight frameworks to boost their productivity. However, if you are experienced in developing enterprise applications outside of this framework (perhaps using C++ and non-Java technologies), you should be able to understand much (if not all) of this book's content.

POJOs in Action is organized into 13 chapters that are divided into four parts. Part 1's two chapters overview POJOs and lightweight frameworks. Part 2's five chapters present a combination of options for using POJOs and lightweight frameworks to effectively design applications. Other approaches for designing the business and database access tiers are taught by the three chapters in Part 3. The final part's three chapters investigate important database-related issues often encountered when developing an enterprise Java application.

Overview of POJOs and lightweight frameworks

Chapter 1 focuses on the disillusionment with EJB. After providing a brief history of EJB, this chapter presents a typical EJB 2.0 application's architecture, highlights the problems with EJB, delves into the shortcomings of procedural design (and why this practice is encouraged by Java EE) and the pain of EJB development, and explores EJB 3.0's attempts to overcome these problems.

This chapter also focuses on POJO-based development, where you learn about the POJO emphasis on object-oriented design, the important benefits of using POJOs, persisting POJOs with Hibernate and JDO, eliminating data transfer objects, making POJOs transactional with Spring, configuring applications with Spring, and deploying a POJO application to the server—not necessarily a full-blown application server. I appreciated the author's money transfer service example, which is based on POJOs, Spring, and Hibernate.

Chapter 2 emphasizes five design decisions for creating enterprise applications. These decisions help you choose among the lightweight POJO approach, the heavyweight EJB 2.0 approach (which is necessary for certain kinds of enterprise applications, as you discover in a later chapter), and the combination POJO/heavyweight approach that EJB 3.0 uses. Chapter 2 walks you through a scenario where a development team addresses each decision in terms of a Food to Go application's use-cases. I found this scenario very helpful.

A simpler, faster approach

Chapter 3 looks at implementing business logic in terms of a domain model (also known as an object model), which is based on some problem domain that you wish to solve. After introducing you to the Domain Model design pattern—which shows you where the domain model fits into the overall application architecture, presents an example domain model based on Food to Go, and introduces the various roles played by classes in the domain model—this chapter walks you through the development of a domain model.

You first learn to identify those features of a problem domain that you can model with classes, attributes, and relationships. You next learn how to add behavior to the domain model. The author reveals his favorite approach for implementing behavior: test-driven development. You discover the importance of refactoring your code, the benefits of using JUnit to perform tests, and a way to simplify and speed up these tests by using mock objects. In closing, Chapter 3 develops a portion of the domain model for one of Food to Go's use-cases.

Chapter 4 explores persisting a domain model in a repository (an object data store). Important concepts include mapping a domain model to a database, accessing the database with an object-relational mapping (ORM) framework, using Spring's ORM support classes, and testing a persistence layer. I especially enjoyed the mapping section. After showing you how to map classes to tables, and object relationship mapping, this section shows you how to map inheritance, manage object lifecycles, and persist object identity.

1 | 2 | 3 | 4 |  Next >

Discuss

Start a new discussion or jump into one of the threads below:

Subject Replies Last post
. Develop enterprise Java applications
By JavaWorldAdministrator
0 10/04/06 09:59 AM
by JavaWorld


Resources