HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

Although I've been following EJB 2.0 very closely, it was only recently that I walked into a project that was the perfect venue for its new features, such as the much enhanced container-managed persistence and local interfaces. And Enterprise JavaBeans, written by Richard Monson-Haefel, fit the bill as a reference and learning guide.

This is a "must-have" book if you want an introduction to EJBs, are migrating from EJB 1.1 to 2.0, or want to build a new application using EJBs. The author provides a brief introduction to distributed objects and component models in the first chapter; however, if you're unfamiliar with these concepts or with database design, this is not the right book for you. Enterprise JavaBeans talks in detail about the obvious - Enterprise JavaBeans - and stays focused on the subject.

I was very impressed with the organization of the book, which made it a treat to read. One of its main strengths is that it stays focused on specific topics and cleanly separates the 1.1 and 2.0 versions of the EJB specification. For example, if you're only concerned with designing a new application using EJB 2.0, the information isn't cluttered with recurring references to the EJB 1.1 CMP model, which is discussed in a separate chapter.

Chapter 1 introduces distributed computing. Chapter 2 provides an excellent overview of EJBs, including coverage of the standard classes and interfaces, the types of beans, and the deployment descriptor for deploying beans. The author has picked a generic application to illustrate his examples - a reservation for a cruise. If this chapter had contained an overall diagram illustrating the entire hierarchy, including the objects developed throughout the book, it would have been a perfect chapter on EJB architecture.

Chapter 3 deals with the basic services provided by the J2EE component transaction monitors or EJB containers. It provides a good discussion on such topics as the EJB life cycle, object persistence, and the bean-container contract. Chapter 4 walks you through developing and deploying some basic EJBs and covers application development concepts from object design to basic database table design. Chapter 5 covers the design of a basic client to access the beans developed in Chapter 4. The discussion on local versus remote interfaces is very helpful.

Chapters 5-8 were, for me, the most useful chapters in the book. Monson-Haefel walks you through the nuts and bolts of designing entity beans with the new EJB 2.0 persistence model. Chapters 6-7 develop sample entity beans in light of the new persistence model with very lucid examples. The organization of the text is excellent. Monson-Haefel begins each example with the abstract programming model, followed by the abstract persistence schema, then the design of the bean interfaces and classes, and finally the deployment of the bean. Each discussion is autonomous and very clear.

Chapter 7 offers clear guidance on database relationships as they relate to EJB 2.0 CMP. Chapter 8 is a good reference for using EJB-QL.

Chapter 9 deals with EJB 1.1 CMP. Chapters 10-11 discuss the details of bean-managed persistence and the EJB container. Chapter 11 has ample coverage of primary keys, the entity context, and the life cycle of entity beans.

Chapters 12-13 cover the other two types of EJBs (session and message-driven beans). The sample application is developed further in these chapters by TravelAgent Bean, Reservation Process Bean, and associated workflows. Transaction design for EJBs is covered in Chapter 14.

Chapter 15 provides some excellent design strategies for EJB design, such as using hash codes to generate primary keys and dependent value objects to pass objects to and from entity beans. Chapter 16 is a reference chapter on the deployment descriptor for EJBs. This is followed in Chapter 17 by an overview of how EJBs fit into the big J2EE picture. The appendices provide concise references to the EJB APIs and the state and sequence diagrams for the different types of EJBs.

This is one of the best sources of information on EJBs that I've found. It would have been helpful if there were some diagrams of the overall picture, but all in all, this is a very well-organized book about using Enterprise JavaBeans to develop applications.

SIDE BARS

Enterprise JavaBeans
Author: Richard Monson-Haefel
Publisher: O'Reilly & Associates

Table of Contents

Preface

1. Introduction
Setting the Stage
Enterprise JavaBeans Defined
Distributed Object Architectures
Component Models
Component Transaction Monitors
CTMs and Server-Side Component Models
Titan Cruises: An Imaginary Business
What's Next?

2. Architectural Overview
The Enterprise Bean Component
Using Enterprise Beans
The Bean-Container Contract
Summary

3. Resource Management and the Primary Services
Resource Management
Primary Services
What's Next?

4. Developing Your First Enterprise Beans
Choosing and Setting Up an EJB Server
Developing an Entity Bean
Developing a Session Bean

5. The Client View
Locating Beans with JNDI
The Remote Client API
EJB 2.0: The Local Client API

6. EJB 2.0 CMP: Basic Persistence
Overview
The Customer EJB
Persistence Fields
Dependent Value Classes
Relationship Fields

7. EJB 2.0 CMP: Entity Relationships
The Seven Relationship Types

8. EJB 2.0 CMP: EJB QL
Declaring EJB QL
The Query Methods
EJB QL Examples
Problems with EJB QL

9. EJB 1.1 CMP
A Note for EJB 2.0 Readers
Overview for EJB 1.1 Readers
Container-Managed Persistence

10. Bean-Managed Persistence
The Remote Interface
The Remote Home Interface
The Primary Key
The ShipBean
Obtaining a Resource Connection
Exception Handling
The ejbCreate( ) Method
The ejbLoad( ) and ejbStore( )
Methods
The ejbRemove( ) Method
The ejbFind( ) Methods
The Deployment Descriptor

11. The Entity-Container Contract
The Primary Key
The Callback Methods
EJB 2.0: ejbHome( )
EntityContext
The Life Cycle of an Entity Bean

12. Session Beans
The Stateless Session Bean
The Life Cycle of a Stateless
Session Bean
The Stateful Session Bean
The Life Cycle of a Stateful Session Bean

13. Message-Driven Beans
JMS as a Resource
Message-Driven Beans

14. Transactions
ACID Transactions
Declarative Transaction Management
Isolation and Database Locking
Nontransactional Beans
Explicit Transaction Management
Exceptions and Transactions
Transactional Stateful Session Beans

15. Design Strategies
Hash Codes in Compound Primary Keys
Passing Objects by Value
Improved Performance with Session Beans
Bean Adapters
Implementing a Common Interface
Entity Beans Without Create Methods
EJB 1.1: Object-to-Relational Mapping Tools
Avoid Emulating Entity Beans with Session Beans
Direct Database Access from Session Beans
Avoid Chaining Stateful Session Beans

16. XML Deployment Descriptors
What Is an XML Deployment Descriptor?
The Contents of a Deployment Descriptor
The Document Header
The Descriptor's Body
Describing Enterprise Beans
EJB 2.0: Describing Relationships
Describing Bean Assembly
The ejb-jar File

17. Java 2, Enterprise Edition
Servlets
JavaServer Pages
Web Components and EJB
J2EE Fills in the Gaps
Fitting the Pieces Together
Future Enhancements

A. The Enterprise JavaBeans API

B. State and Sequence Diagrams

C. EJB Vendors

Index

Author Bio
Ajit Sagar is the J2EE editor of JDJ and the founding editor and editor-in-chief of XML-Journal. A lead architect with Metavonni, LC, based in Dallas, he's well versed in Java, Web, and XML technologies. [email protected]

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.