Developing EJB 2.0 Components

  • Authors:
  • Pravin V. Tulachan

  • Affiliations:
  • -

  • Venue:
  • Developing EJB 2.0 Components
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

Abstract

From the Book:PrefaceWhat Are Enterprise JavaBeans (EJB)?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.Why Should You Buy This Book?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 categories—standalone EJB books that focus solely on EJB and do a good job at it but usually lack context, and books that attempt to cover everything—all the J2EE technologies, CORBA, and even (in some cases) COM/DCOM, in one humongous tome. Theselatter 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 programmers—nationally, internationally for Netscape, and currently for Sun—how 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.Go the Whole Nine YardsLet'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 them—no 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.Respect Your IntelligenceOne 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.Advanced EJB Concepts...When You're Ready for ThemI'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.Repetition is the Key to LearningThe 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.What This Book Doesn't CoverI'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.Vendor NeutralityThis 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 requirements—it 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.Not a Java Programming BookThis book doesn't teach you Java programming—only how to write business applications using EJBs.Servlet, JSP, SQL, JDBC, UML, or CORBA Not CoveredThis 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.Audience for This BookThis 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.How the Book Is OrganizedThe book consists of eighteen chapters and is organized in three parts. Part 1: OverviewThe first part of this book consists of two introductory chapters that give an introductory, non-technical overview of the Java 2 Enterprise Edition and Enterprise JavaBeans 2.0. Audiences who will benefit from this section are novice Java programmers and nonprogrammers (such as technical managers, project managers, and so forth) who can read these two chapters and get a good grasp of the fundamentals of J2EE (1.3) and EJB (2.0) technologies. The information in these chapters will help them communicate effectively with EJB programmers.Chapter 1: Introduction to Java 2 Enterprise Edition 1.3—This chapter is a basic, nontechnical introduction to Java 2 Enterprise Edition. It discusses the various Java technologies required by the J2EE 1.3 specification and how they all fit together.Chapter 2: Introduction to Enterprise JavaBeans 2.0—This chapter is an introduction to Enterprise JavaBeans 2.0 and discusses the basics of Enterprise JavaBeans without overwhelming the reader with technical details.Part 2: Developing EJBsThe 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.Chapter 3: Overview of Sample Applications—This chapter offers a high-level implementation overview of sample applications of stateless and stateful session beans, bean-managed persistent and container-managed persistent entity beans, and message-driven beans.Chapter 4: The EJB Client View—This chapter discusses the local and remote client view of EJB and rules for implementing remote and local interfaces and their advantages and disadvantages.Chapter 5: Introduction to Session Beans—Here, you'll be introduced to characteristics, APIs, and details of session beans.Chapter 6: Developing Stateless Session Beans—This chapter covers the life cycle of stateless session beans and provides a step-by-step guide to implementing, packaging, assembling, and deploying a stateless session bean sample application.Chapter 7: Developing Stateful Session Beans—This chapter describes the life cycle of stateful session beans and provides a step-by-step guide to implementing, packaging, assembling, and deploying a stateful session bean sample application.Chapter 8: Introduction to Entity Beans—This chapter discusses the basic characteristic of entity beans, their life cycle, API, and rules for writing entity beans.Chapter 9: Developing Bean-Managed Entity Beans—This chapter povides a step-by-step guide to implementing, packaging, assembling, and deploying a BMP entity bean sample application.Chapter 10: CMP 2.0: Abstract Persistence Model and EJB QL—This chapter helps you understand the concepts behind the abstract persistence schema and the EJB Query language.Chapter 11: Developing CMP 2.0 Entity Beans—These pages offer a step-by-step guide to implementing, packaging, assembling, and deploying a CMP entity bean sample application.Chapter 12: Java Message Service—This chapter discusses the JMS API, messaging models, and how to use JMS APIs.Chapter 13: Developing Message-Driven Beans—This chapter is a step-by-step guide to implementing, packaging, assembling, and deploying a message-driven bean sample application.Part 3: Advanced TopicsThe final section in the book discusses advanced EJB concepts, including transaction, security, EJB design patterns, and migration issues.Chapter 14: Transactions—This chapter discusses how to implement programmatic and declarative transactions in different types of EJBs.Chapter 15: Enterprise JavaBean Security—This chapter discusses security concepts and how to implement programmatic and declarative security in EJBs.Chapter 16: EJB Design Patterns, Interoperability, and Performance—This chapter discusses common EJB design patterns and issues with performance and interoperability in EJB 2.0.Chapter 17: Migrating EJB 1.1 Applications to the EJB 2.0 Container—This chapter discusses issues involved in migrating EJB 1.1 beans to EJB 2.0 containers. It includes details and steps for migration of a sample application.Chapter 18: Assembling the J2EE Online Registration Application—The final chapter takes some of the discrete EJBs components developed in Part 2 of the book, refactors them if necessary, applies appropriate design patterns, and creates a complete application. It also discusses some of the implementation issues.AppendixAt the back of the book, you will find instructions on how to download, install, and set up Sun's J2SDKEE 1.3 Reference Implementation. For the latest updates, please go to the companion Web site at http://www.J2EEBootCamp.com and download Appendix.pdf.Companion Web SiteTo 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 pvt@j2eebootcamp.com, and I'll do my best to respond within a few days.What's a Giraffe Doing on the Front Cover of an EJB Book?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