Enterprise JavaBeans: Developing Component-Based Distributed Applications
Tom Valesky · Medical Entomology and Zoology · 1999
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. 2. EJB's Architecture. 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. 3. Hello, EJB! 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. 4. Writing EJB Session Beans. 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. 5. Writing EJB Entity Beans. 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. 6. EJB Clients. 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. 7. Deployment. 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. 8. Tips, Tricks, and Traps for Building Distributed and Other Systems. 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. 9. A Nontrival Example. 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. 10. Implementations and Future Directions. EJB Implementations. WebLogic. EJBHome. Other EJB Vendors. Future Directions for EJB. Sun's EJB Roadmap. A Bit of Stargazing. Conclusion. Appendix A Source Code for Chapter 4. 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. Appendix B Source Code for Chapter 5. 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. Appendix C Source Code for Chapter 9. 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. Glossary. Index. CD-ROM Warranty. 0201604469T04062001