Register your product to gain access to bonus material or receive a coupon.
Enterprise JavaBeanso facilitates the development of distributed Javao applications, providing an object-oriented transactional environment for building distributed, component-based, multitier enterprise applications.
Enterprise JavaBeans is designed to get you up-to-speed quickly, focusing on the exact information you need to become an effective Enterprise JavaBeans programmer. This example-filled book serves as an introduction and tutorial, and provides the in-depth information you need to handle real-world programming challenges.
This book presents an overview of the architecture, using a "Hello, world!" Enterprise JavaBeans system to illustrate basic concepts. The book then moves on to cover Session and Entity beans, how to write client programs that use Enterprise JavaBeans, and the packaging and deploying of Enterprise JavaBeans. You will find precise explanations on specific topics such as:
In addition, substantial examples and an "implementation diary" demonstrate the implementation process, the available options and tradeoffs, and the rationale behind development choices. A chapter devoted to tips and common pitfalls provides concrete rules of thumb for more effective Enterprise JavaBeans programming. The accompanying CD-ROM includes Enterprise JavaBeans software and examples from the book.
Enterprise JavaBeans gives you the background you need to use the system productively in your daily work and puts you on the fast track to mastering Enterprise JavaBeans techniques.
Click below to download the current version of Weblogic related to this title:
Weblogic Information
Click below for Source Code related to this title:
valeskyb.zip
Click below to download the current version of Weblogic related to this title:
Weblogic Information
Foreword.
Preface.
1. The Big Picture.
Introduction.
Transaction Processors.
ACID Properties of Transactions.
OLTP Versus OLAP.
Two-Tier, Client-Server Architecture.
Three-Tier Architecture.
Sockets.
RPCs.
CORBA.
RMI.
OLE/DCOM.
Message Queues.
Distributed Transaction Processing.
EJB's Role.
Conclusion.
Logical Architecture.
Overview of EJB's Software Architecture.
EJB Servers.
EJB Containers.
Enterprise Beans.
A High-Level View of an EJB Conversation.
Finding the Bean.
Getting Access to a Bean.
Calling the Bean's Methods.
Getting Rid of the Bean.
RMI Clients.
CORBA Clients.
Building and Deploying EJBs.
Writing the EJB.
Deploying the EJB.
Connecting to the EJB.
Roles in EJB.
Enterprise Bean Provider.
Deployer.
Application Assembler.
EJB Server Provider.
EJB Container Provider.
System Administrator.
Requirements.
Design.
Implementation.
Step 1: Create the Remote Interface for the Bean.
Step 2: Create the Bean's Home Interface.
Step 3: Create the Bean's Implementation Class.
Step 4: Compile the Remote Interface, Home Interface, and Implementation Class.
Step 5: Create a Session Descriptor.
Step 6: Create a Manifest.
Step 7: Create an ejb-jar File.
Step 8: Deploy the ejb-jar File.
Step 9: Write a Client.
Step 10: Run the Client.
What's Really Going on Here?
Conclusion.
When to Use Session Beans.
Constraints on Session Beans.
Session Bean Life Cycle.
Transactions and EJB.
Stateful Session Bean Example.
Requirements.
Design.
Implementation.
Summing Up the Stateful Session Bean Example.
Stateless Session Bean Example.
Requirements.
Design.
Implementation.
Deploying the Example.
Conclusion.
When to Use Entity Beans.
Concurrent Use by Several Clients.
Long Lifetime.
Survival of Server Crashes.
Direct Representation of Data in an Underlying Database.
Bean-Managed Versus Container-Managed Persistence.
Primary Keys.
Entity Bean Life Cycle.
Nonexistence.
The Pooled State.
The Ready State.
Reentrant Instances.
Example: Container-Managed Persistence.
Requirements.
Design.
Implementation.
Example: Bean-Managed Persistence.
Requirements.
Design.
Implementation.
Conclusion.
An EJB Bean as a Client to Another Bean.
The Home Interface.
The Remote Interface.
The EJB Client Bean.
The Client.
Serializing a Handle.
The Client.
Invoking the Client.
Transactions in Clients.
Authentication in Clients.
Getting Metadata.
A Servlet Client.
HTML to Make a Call to the Servlet.
Setting Up WebLogic Servlets.
An Applet Client.
The Applet Tag.
CORBA Client Example.
What to Look for in a CORBA-Compliant EJB.
Implementation.
HTTP Tunneling and SSL.
Conclusion.
The DeploymentDescriptor Class.
The AccessControlEntry Class.
Back to the DeploymentDescriptor Class (I).
The ControlDescriptor Class.
"Run-as" Modes.
Back to the DeploymentDescriptor Class (II).
The SessionDescriptor Class.
The EntityDescriptor Class.
Example Program.
The Home Interface.
The Remote Interface.
The Bean Implementation Class.
The Client.
Using Roles at Runtime.
The ReadDD Class.
The Deployment Descriptor.
Setting Up Access Control Lists.
Container-Managed Finder Methods.
Other Deployment Issues.
Caching Issues.
Persistent Storage.
Properties.
Other Administrative Issues.
Conclusion.
Expect Your Network Connections to Fail.
Test Catastrophic Failure.
Avoid Remote Method Invocations Where Possible.
Treat Transactions and Database Connections as Precious Resources.
Monitor the Granularity of Objects.
Monitor the Granularity of Methods.
Isolate Vendor-Specific Code.
Avoid Making Entity Beans Reentrant.
Observe Programming Restrictions on EJB Beans.
Don't Implement the Bean's Remote Interface in Its Implementation Class.
Use Relatively Small and Well-Defined Queries.
Don't Keep Database Cursors Open.
Minimize Transactions.
Minimize Distributed Transactions.
Avoid Indexing Your Tables.
Remember That Memory Is Cheap.
Build in Upward-Scalability.
Wrap Entity Beans with Session Beans.
Streamline Your Middleware Methods.
Put Your Business Logic in the Middle Tier.
Understand the Tradeoffs Between Isolation Level and Concurrency.
Avoid Extensive Object Allocation and Deallocation.
Prototype, Prototype, Prototype.
Do Load Testing.
Monitor the Size of Your User Base When Designing an Architecture.
Separate Transaction-Processing Tables from Reporting Tables.
If a Database Query Runs Slowly, Review Its Query Plan.
Keep Joins Simple.
Have a Database Administrator.
Use Prepared Statements.
Have Your Development Environment Mirror Your Production Environment.
During Load Testing, Use a Sniffer to Monitor Network Traffic.
Use the Facade Pattern for Interfacing with Legacy Systems.
Use Patterns.
Keep Network Topology in Mind.
Design Security in from the Start.
Work Closely with Network Personnel.
Be Aware of Internal Politics.
Be Aware of the Organizational Culture.
Be Prepared for Requirements Changes.
Build One Slice at a Time.
Build the Difficult Components First.
Talk to Your Users.
Keep It Simple.
Conduct Walkthroughs.
Use Version Control.
Use a Code Profiler.
Establish Your Interfaces Early.
Build Early and Often.
Perform Regression Testing.
Choose Appropriate Test Cases.
Generate Test Cases While Implementing the Application.
Automate Everything.
Understand the Role of Testing.
Requirements.
Design.
Relationships in EJB.
Relationships in General.
Detailed Design.
Database Design.
Detailed Design of the TimeTracker Class.
Detailed Design of the Employee Class.
Designing the TimeSheetHash Class.
Designing the Client.
Implementation.
Building the Database.
Setting Up the Access Control Lists.
Implementing the Employee Bean.
The Final Product.
Employee Home Interface.
Employee Remote Interface.
Employee Implementation.
Employee Primary Key Class.
EmployeeInfo Class.
MyIdentity Class.
TimeSheetLine Class.
TimeSheetHash Class.
The Deployment Descriptor.
Implementing the TimeTracker Bean.
The Home Interface.
The Remote Interface.
Exceptions.
Notes About the Implementation Class.
The Deployment Descriptor.
Implementing the Real Client.
The Client Implementation Class.
An Applet to Run the Client.
Deployment Issues.
Conclusion.
EJB Implementations.
WebLogic.
EJBHome.
Other EJB Vendors.
Future Directions for EJB.
Sun's EJB Roadmap.
A Bit of Stargazing.
Conclusion.
Home Interface for Bag Example.
Remote Interface for the Bag Example.
InventoryItem Class.
ItemNotFoundException Exception.
BagBean Implementation Class.
BagBean Client.
Bag2 Home Interface.
Bag2 Remote Interface.
Bag2 Bean Implementation.
Bag2 Client.
Implementation of OrderBean (Container-Managed Persistence).
Client for Container-Managed Entity Bean.
Implementation Bean for Bean-Managed Persistence.
Client for the Bean-Managed Persistence Example.
Implementation of the Employee Entity Bean.
Deployment Descriptor for the Employee Entity Bean.
Implementation Class for the TimeTracker Session Bean.
Deployment Descriptor for the TimeTracker Session Bean.
TimeTracker Client Implementation.
This book discusses Enterprise JavaBeans (EJB). It assumes that you have basic knowledge of Java, but does not assume detailed knowledge of distributed computing. The primary goal of this book is to provide a relatively short and easy-to-read document that will get you up to speed quickly on how to develop EJB. Its secondary goal is to serve as a good companion text for a short course on EJB development.
Chapter 1 provides an overview of EJB--that is, what it is and where it fits into the world of distributed computing. If you're looking for technical details, you won't find them in this chapter. Nevertheless, this discussion provides some background that you can use to convince your manager that EJB is a good thing.
Chapter 2 offers an overview of the EJB architecture. It describes the various components that make up an EJB system and covers the major classes and interfaces used in the development of an EJB bean.
Chapter 3 is the first chapter that contains coding examples. It presents a "hello, world!" EJB system. The "hello world" example was chosen for two reasons. First, in coming to terms with a new technology, a simple example is useful in helping you to figure out the core components of the system. Second, the main intent in this chapter is to highlight the steps you need to perform to write and deploy an EJB bean; in this case, a simpler bean provides fewer distractions from this discussion.
Two types of EJB beans exist: Session beans and Entity beans. Chapter 4 covers Session beans. It discusses the differences between stateful and stateless beans, and provides examples of each.
Chapter 5 discusses Entity beans. It describes the differences between bean-managed and container-managed entity beans, providing an example of each.
In Chapter 6, the issue is writing client programs that use EJB beans. It includes quite a few examples, including those demonstrating
Chapter 7 focuses on the process of packaging and deploying EJB beans. It includes a detailed discussion of deployment descriptors and the values they contain. It also examines access control lists and shows how to use them to set up permissions on an EJB server. In addition, Chapter 7 includes an example that shows how a bean can retrieve and test a client's identity.
Chapter 8 contains a set of tips for constructing distributed systems--or any other type of system, for that matter. The goal of this chapter is to provide you with some concrete rules of thumb that you can use in your own development process and to help you avoid making a few common mistakes.
Chapter 9 includes a relatively nontrivial example program (a time management system) and a sort of "implementation diary" in which the author describes the process used to create the example. This process involves assessing the options available, analyzing the tradeoffs among them, and making the final choices.
In Chapter 10--the "wrap-up" chapter--currently available EJB servers are discussed. Currently, relatively few implementations are available, so we also discuss EJB servers that are not available as of this writing, but should be out soon. This chapter concludes with a discussion of the future of the EJB specification; fortune-telling is a risky business, so the predictions generally stick to issues that are certain to be included in future versions of the EJB standard.
As noted earlier, the goal of this book is to provide you with a quick but thorough introduction to EJB--quick, so you can start using EJB soon, and thorough, so that you won't be flummoxed by real-world situations because only a few canned examples were involved. If you have any comments or suggestions for improvement, please send me an e-mail at tvalesky@patriot.net.
It is a fact of life that the EJB specification and its associated documents will undergo some evolution over the next few years. To accommodate these changes, we've made an online supplement to this book available. This supplement will track changes and new developments in the specification, include new examples that demonstrate new capabilities for EJB, and generally keep you up-to-date with what's going on in the EJB world. Be sure to stop by.
A note on Java versions is in order here. The examples in this book were developed in JDK 1.1, and the accompanying WebLogic software should be run under JDK 1.1 Throughout this book, notations have been made where things will change under Java 2 (formerly known as JDK 1.2). For late-breaking news, refer to his book's companion Web site.
A note about the formatting of the code examples: In the source code in this book, all actual new lines begin with a line number. In some cases, the lines were too long to be displayed correctly and have wrapped around to a new line. So, if you see a line in one of the examples like line 15 here:
15 System.out.println("this is a very very very long line"); 16 System.out.println("this is shorter");
rest assured that all is well with the actual code. Acknowledgments Thanks to the WebLogic folks, especially Bob Pasker and Sriram Srinivasan. Their support has been first-rate.
Thanks to Jonathan K. Weedon of Inprise Corporation for the CORBA client example.
Thanks to the folks on the EJB-INTEREST list, for many happy hours of conversation about EJB, and for serving as a sounding board for many of my ideas.
Thanks to the team at EJBHOME for developing a freeware EJB implementation. The word will spread faster if the price of entry is not into five figures.
Thanks to the reviewers of this manuscript, James D. Frentiss, Liane Acker, Gary McGraw, Ajit Sagar, J. Patrick Ravenal, Ethan Henry, and Jim Inscore, all of whom helped clarify and refine the manuscript.
Thanks to my teachers.
Thanks to Russ Marshall and the gang at BLS, for giving me my first programming job at a time when I had few qualifications other than enthusiasm, and for showing me the value of good requirements and thorough testing.
Thanks to the folks at Javasoft, for changing the world.
Thanks to David Kodama and Dana Gardner, my long-suffering editors at Advisor Publications, for keeping me honest.
Thanks to the staff at Addison Wesley Longman, especially Elizabeth Spainhour, Mary O'Brien, and Maureen Willard.
Thanks to Mom and Dad for putting me through college. Top o' the world, Ma!
--Tom Valesky