NEW TITLE RELEASE ANNOUNCEMENT
See the latest about a temporary release delay on new titles. Learn more.
A practical guide to Enterprise JavaBeans 2.0 technology.
Developing EJB 2.0 Components is a "nuts and bolts" guide to real-world EJB 2.0 component architecture development. Whether you're new to the J2EE platform or upgrading from previous versions, leading developer and trainer Pravin Tulachan shows you how to make the most of EJB 2.0 technology within the context of the J2EE 1.3 platform. You won't just learn how to use session, entity, and message-driven beansyou'll learn how to leverage J2EE technology to maximize the functionality and robustness of every component you create. Coverage includes:
Many chapters include a complete, easy-to-adapt project. In addition, Tulachan integrates these projects into a full-fledged enterprise application that demonstrates every key facet of EJB 2.0 technology.
Take full advantage of the J2EE platform with the one book that shows you how-Developing EJB 2.0 Components.
Developing EJB 2.0 Components delivers hands-on coverage of:
(NOTE: Each chapter concludes with a Summary.)
I. OVERVIEW.1. Introduction TO Java 2 Enterprise Edition 1.3.
The Evolution of Enterprise Computing. Considerations of Enterprise Computing. Enterprise Computing Platforms. Technologies Required by J2EE 1.3. The J2EE Architecture. Technical Advantages of the J2EE Architecture. Business-Related Advantages of the J2EE Architecture. J2EE Development and Deployment Roles. Developing a J2EE Application. J2EE Disadvantages.2. Introduction to Enterprise JavaBeans 2.0.
The Software Component Model. Enterprise JavaBeans Architecture. EJB Security. EJB Advantages. EJB Disadvantages. Differences between Enterprise JavaBeans and JavaBeans.
II. DEVELOPING EJBS.3. Overview of Sample Applications.
Naming Conventions. Locating Example Source Code. Database Tables. Sample Application Descriptions.4. The EJB Client View.
Distributed Objects. Introduction to JNDI. JNDI in a Client Application. JNDI and EJBs. Introduction to RMI-IIOP. The EJB Client View. Remote and Local Interfaces. Local and Remote Interface APIs. Rules for Writing Remote and Local Interfaces. Creating a Remote Client Application. Compiling and Executing HelloWorld. Packaging the HelloWorld Application. Using the Local or the Remote Interface. Application Performance.5. Introduction to Session Beans.
Session Bean Characteristics. Types of Session Beans. Session Bean Elements. Writing Session Beans: Rules and Requirements. Roles of the Deployment Tool in Implementing Session Beans. Packaging a Session Bean. Deployment.6. Developing Stateless Session Beans.
Characteristics and Features of Stateless Session Beans. Stateless Session Bean Life Cycles. A Stateless Schedule Bean Application.7. Developing Stateful Session Beans.
Characteristics of SFSBs. When to Use SFSBs. The SFSB Life Cycle. Implementing a Shopping Cart Application.8. Introduction to Entity Beans.
Overview. Entity Bean Characteristics. Types of Entity Beans. Life Cycle of an Entity Bean. Entity Bean Elements. Rules for Implementing the Entity Bean Class. Rules for Method Implementation. Comparing BMP and CMP Entity Beans. Concurrent Access in Entity Beans. Differences between Session and Entity Beans. Object Identity, Handle, and Primary Key. New Features of CMP 2.0 Entity Beans.9. Developing Bean-Managed Entity Beans.
BMP Characteristics. Bean-Managed Persistence. BMP Sample Application.10. CMP 2.0: Abstract Persistence Model and EJB QL.
CMP 2.0 Entity Bean Architecture. EJB Query Language. Rules for Writing CMP 2.0 Entity Bean Classes. Rules for Writing Abstract Accessor Methods. Rules for Writing Dependent Value Classes. Rules for Writing ejbSelect Methods. Responsibilities in CMP Entity Bean Development. Comparing BMP and CMP Entity Beans. The Primary Key for CMP 2.0 Entity Beans.11. Developing CMP 2.0 Entity Beans.
Characteristics of CMP 2.0 Entity Beans. Advantages of CMP Entity Beans over BMP Entity Beans. CMP 2.0 Entity Bean Sample Application.12. Java Message Service.
Introduction to Java Message Service. JMS Architecture. Messaging Domain Models. The JMS Programming Model. JMS Integration with EJBs.13. Developing Message-Driven Beans.
Characteristics of MDBs. Elements of MDBs. The Life Cycle of MDBs. Comparing MDBs with Session and Entity Beans. Rules for Writing the MDB Class and Its Methods. MDB EJB Sample Application: RosterMDB. RosterApp Deployment Descriptors.
III. ADVANCED TOPICS.14. Transactions.
An Introduction to Transactions and Their Benefits. The Transaction Model. ACID Properties of a Transaction. Transaction Attributes. Implementing Transactions Programmatically or Declaratively. Transaction Behavior of SFSB, BMP, and CMP Entity Beans. Initiating a Transaction. Bean-Managed versus Container-Managed Transaction Demarcation. Isolation Levels. Transaction Roles and Responsibilities.15. Enterprise JavaBean Security.
Understanding the EJB Security Model. Roles in Implementing EJB Security. Implementing Security Declaratively. Implementing Security Programmatically. Declarative versus Programmatic Security. Implementing Resource Manager Security. Security Applicability and Restrictions. Security Interoperability. Roles and Responsibilities in Implementing Security.16. EJB Design Patterns, Interoperability, and Performance.
Introduction to EJB Design Patterns. Data Access Object. Value Object. Value Object Assembler. Value List Handler. Service Locator. Session Façade. Business Delegate. Additional Patterns. EJB Interoperability. EJB Performance Issues.17. Migrating EJB 1.1 Applications to the EJB 2.0 Container.
Migration Options and Approaches. EJB 1.1 Shortcomings. Migrating EJB 1.1 Applications to EJB 2.0.18. Assembling the J2EE Online Registration Application.
Design Goals. Applying Design Patterns. Refactoring Existing EJBs. Assembling and Deploying the Application. Final Thoughts.19. Installing and Running Sun Reference Implementation J2SDKEE 1.3.
Installation Requirements. Installation Overview in Brief. Setting up the Development Environment. Setting up the Application Environment. Preparing the J2SDKEE for Operation.Index.
If you've picked up this book and are reading this page, it's probably because you're curious about or interested in Enterprise JavaBeans (EJB), Java 2 Enterprise Edition, or Java. Or perhaps you just liked the cute giraffe on the cover with its backdrop of Mt. Kilimanjaro and wondered what a giraffe was doing on a cover of a J2EE book.
This book is about Enterprise JavaBeans 2.0. EJB is a component model for building scalable, reusable, portable, transactional, and distributed enterprise business applications. Well-designed EJBs encapsulate discrete business logic, and EJBs that encapsulate different kinds of business logic can be assembled to form a complete business application. For example, one could take discrete EJBs that implement user authentication, credit card authorization, shopping cart, order fulfillment, inventory management, and customer relationship management tasks and assemble them into one integrated application, then add the Web front end and ... presto! You have an e-commerce application, are ready for an IPO (well, that was true back in 1999 and early 2000), and can afford to buy a two-bedroom mansion in Silicon Valley. We'll worry about profitability later.
There are several good books on EJBs, and I'm sure there will be more in the future. Most current EJB books fall into two basic categoriesstandalone EJB books that focus solely on EJB and do a good job at it but usually lack context, and books that attempt to cover everythingall the J2EE technologies, CORBA, and even (in some cases) COM/DCOM, in one humongous tome. These latter books have plenty of breadth but usually lack depth.
This book, Developing EJB 2.0 Components, the first book in a three-book series, focuses exclusively on the practical aspects of how to implement EJB 2.0. It is an attempt to bring the right balance between depth and breath within the broader context of the Java 2 Enterprise Edition platform. The book incorporates a unique perspective from my experience as a J2EE developer and as an instructor who teaches Java programmersnationally, internationally for Netscape, and currently for Sunhow to develop J2EE applications. The second book in the series, Developing Web Components and Web Services, will focus exclusively on the presentation and user-interaction aspects of the J2EE technologies. The third (as yet untitled) book will focus exclusively on the J2EE infrastructure technologies. Together, these three titles will provide the audience with the necessary practical knowledge, depth, and breadth to write robust J2EE applications.
So you must be wondering, "Why should I buy this book?" Following are some good reasons (my reasons, of course), but you be the judge.
Let's face it: EJB has a steep learning curve. Implementing EJB applications can be complex, and knowing how to write an EJB component is just half of the challenge. After coding and compiling the EJB components, you need to package, assemble, and then deploy themno trivial tasks for a beginning EJB developer. Unlike most EJB books, Developing EJB 2.0 Components not only has chapters that discuss the theory, the APIs, and the rules on writing various types of EJBs and their methods, but it also has a separate chapter that discusses step-by-step implementation details followed by packaging and deployment steps and information on how to run the sample application. This information is complete with a copious number of diagrams and screen captures of the steps to guide you to a successful completion for each type of EJB. If my instructor-lead training experience is any indication, most rookie EJB developers will appreciate my effort to show you how to "go the whole nine yards" (to borrow an expression from American football), or in other words, to implement a complete solution.
One of the hardest tasks in writing a book like this is setting the level at which to write the sample applications. On one hand, they shouldn't be so long and complicated that they distract the attention of the audience from fundamental EJB concepts in the process of trying to figure out complicated and nifty algorithms. At the other extreme, the sample applications shouldn't be so simple that they add little or no value to the learning process. My view is that I respect your intelligence and don't need to impress you with complex examples, so I've taken the middle path. The sample applications are not too complicated and not too long, so you can focus on the fundamentals of EJB without being too simplistic. Once you've mastered the concepts, you can take the sample application and use it to add real-world business complexity to your own applications. Most of the examples implement discrete business logic per EJB, and the last chapter takes all the EJBs you've implemented in the previous chapters and assembles them into an integrated EJB application, applying EJB design patterns and best practices. I hope I've been successful with this approach.
I've purposely deferred discussing advanced and complex issues such as transactions, security, and design patterns in Part 3 of the book so as to focus on the fundamentals of EJBs. Once you've mastered the fundamentals of EJB 2.0, you can then dive into more advanced concepts in Part 3. In that section, we concentrate on how to implement EJB transactions, EJB security, EJB design patterns, and strategies for migrating from EJB 1.1 to EJB 2.0, with complete code examples.
The approach this book takes is first to discuss the concepts, characteristics, APIs, and rules on how to write specific EJB in an introductory chapter and then follow up with an implementation chapter that repeats the key concepts and rules during step-by-step implementation of a sample code example. I believe the discussion of the EJB fundamentals, followed by reinforcement through repetition of key concepts with example code, helps reduce the learning curve.
I've told you all the great reasons why you should buy this book, so in the interest of fairness, I'll be up front and tell you that in some cases, you might not want to buy it. Here's why.
This book doesn't discuss packaging, assembling, and deploying using BEA's Weblogic, IBM's Websphere, Sun's iPlanet, or any other brand-name application server. The EJB implementation details are standard, so they're applicable to all application servers. This book focuses on packaging, assembling, and deploying EJB applications using Sun's J2EE Reference Implementation's deployment tool (deploytool), so the instructions are specific to that tool. The main reason I chose J2SDKEE RI is the resource requirementsit requires less than 15 MB of drive space, features ease of installation, runs with 128 MB of RAM, and is free. Most brand-name application servers require 100 MB of disk space and a minimum of 256 MB of RAM (or more), and installations can be challenging.
This book doesn't teach you Java programmingonly how to write business applications using EJBs.
This book assumes that the reader has real-world Java programming experience and also has familiarity with HTML, servlet, JSP, SQL, JDBC, and CORBA. I use UML diagrams and assume you have basic familiarity with such diagrams.
This book is primarily geared toward helping new EJB programmers and existing EJB 1.1 programmers learn how to write business logic in EJB 2.0. The ideal reader should have at least one year of Java programming experience and be familiar with HTML, servlet, JSP, SQL, rmi, and JDBC.
The book consists of eighteen chapters and is organized in three parts.
The second part of this book is geared toward Java programmers and EJB programmers who are interested in learning how to implement EJB 2.0. The chapters in this section deal with theory, followed by a step-by-step guide to implementing, packaging and deploying session, entity, and message-driven beans.
The final section in the book discusses advanced EJB concepts, including transaction, security, EJB design patterns, and migration issues.
http://www.J2EEBootCamp.comand download Appendix.pdf.
To keep the book within reasonable number of pages, the book lists no examples in their entirety but instead takes code snippets from the sample examples to elucidate key concepts during the discussion. The complete source code, along with compiled classes and deployable ear files, are available for download from the companion Web site,
http://www.J2EEBootCamp.com. I encourage you to return here for the latest on bug fixes, new articles, new sample examples, and my public speaking engagements.
Feel free to send comments and suggestions to
firstname.lastname@example.org, and I'll do my best to respond within a few days.
I'm an avid adventure traveler, and as a server-side Java consultant working in Silicon Valley, I've been able to travel two months a year for the past several years, thanks to the Internet boom (ah, those good old days!). I always had a vague notion of writing a Java book someday, and it became a real-life goal during a long trip across East Africa-to be precise, at the top of Mt. Kilimanjaro on January 1, 2000 at the first sunrise of the millennium. So the picture on the cover of the book is my tribute to the majestic Mt. Kilimanjaro (the highest mountain in Africa), its amazing wildlife, and the diverse cultures and peoples of Africa.AcknowledgmentsTo put it positively (and mildly), writing this book has been one of the most challenging experiences of my life. I know you've read such statements by other authors-and so have I-but it really is a challenge, trust me. Even though the book has only my name on it, there are many talented people who've played significant roles in making this book possible. Without their assistance, this book would not have become a reality.At Prentice Hall, I would like to express my gratitude to executive editor Greg Doench for accepting the J2EE book series proposal and bringing it to fruition. My thanks also go to marketing manager Debby vanDijk and acquisition editor Eileen Clark for all their efforts toward the completion of the book. I would also like to thank developmental editor Jim Markham for helping me with the development and structure of the book.Thanks also go to production coordinator, editor, and compositor Sybil Ihrig of Helios Productions, technical reviewer Rob Gordon, and editors Casey Andrysiak and Elizabeth Hayes for their meticulous reviews and suggestions regarding the content and style of the book. At Sun Press, I wish thank Michael Alread and Rachel Borden for their efforts in expediting production of the book.I would also like to express my thanks to three excellent authors-Phillip Heller (The Complete Java Certification), Marty Hall (Core Servlet and JavaServer Pages), and Peter Haggar (Practical Java Programming Guide) for their initial encouragement with my book. The acknowledgment list would be incomplete without expressing my deep appreciation to Jason Fish, business development manager at Sun Educational Services, for introducing me to Greg Doench at Prentice Hall and thus starting the ball rolling on the this book. Thanks, Jason.-Pravin Tulachan