1 / 51

Chapter 8 Evaluating Candidate Technologies for Control and Entity Classes

Chapter 8 Evaluating Candidate Technologies for Control and Entity Classes. 鄧姚文 joseph@im.knu.edu.tw http://w3.im.knu.edu.tw/~joseph. Agenda. RMI JDBC EJB 1.1 Sample technology selection. RMI. Remote method invocation

Download Presentation

Chapter 8 Evaluating Candidate Technologies for Control and Entity Classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 Evaluating Candidate Technologies for Control and Entity Classes 鄧姚文 joseph@im.knu.edu.tw http://w3.im.knu.edu.tw/~joseph OOAD

  2. Agenda • RMI • JDBC • EJB 1.1 • Sample technology selection OOAD

  3. RMI • Remote method invocation • Allows a client on one host to call methods on an object that resides on another host OOAD

  4. RMIGory Details OOAD

  5. OOAD

  6. OOAD

  7. RMI Gory DetailsRemote Object Registration OOAD

  8. RMI Gory DetailsParameter Passing • Primitives • Serializable objects • Ignores transit objects • Implements java.io.serializable • Remote reference as parameters • Implements java.rmi.RemoteObject • Their stubs are serialized and sent in their place OOAD

  9. RMI Gory DetailsThread Safety • Accessed by concurrent threads • It is up to the developer to make sure that any resources shared among client requests are thread-safe • Synchronize methods or code blocks OOAD

  10. RMI Gory DetailsDevelopment and Deployment • Write remote interfaces and implementations for the server • Use the rmic command to generate stub classes • Write client applications • Distribute stub classes and any common domain classes to the client • Start the RMI registry • Run the main application to register the remote objects with the registry • Start the client OOAD

  11. RMICommon Uses of RMI • Remote object that hides entity objects • Strict layering • Direct access to entity objects • Relaxed layering • Direct access to entity objects with event notification • The observer pattern OOAD

  12. OOAD

  13. OOAD

  14. OOAD

  15. RMI • Strengths • Distributed application • Elegant and easy to assimilate • Cross platform • Weaknesses • Leave scalability, fault tolerance, load balancing, and data integrity concerns up to the developers OOAD

  16. RMI • Compatible technologies • RMI + JDBC • RMI remote objects can be called by any java code • Cost of adoption • Architect • RMI developer OOAD

  17. JDBC • Java DataBase Connectivity • Allows developers to write database-independent code while still getting the performance of drivers OOAD

  18. JDBCGory Details • Drivers, connections, and statements • New and improved result sets OOAD

  19. OOAD

  20. OOAD

  21. OOAD

  22. RMI • Strengths • Database-independent code • Weaknesses • Transaction management • Connection pooling OOAD

  23. JDBC • Compatible technologies • Can be used to access a database from any java code • Cost of adoption • Architect • JDBC developer OOAD

  24. JDBC Suitability of RMI and JDBC • Number and type of users • A small number of dedicated users, general use within an organization • A large audience with high interest • Do not scale well • Performance and scalability • For read-only systems and for systems that allow isolated updates OOAD

  25. EJB 1.1 • Enterprise JavaBeans • Java 2 enterprise edition • A framework that exposes objects to remote clients • Object caching • Transaction management • Object-to-relational persistence • Security OOAD

  26. Entity bean Home interface Session bean Remote interface Implementation Deployment descriptor Bean-managed persistence Container-managed persistence Transaction boundaries Container Persistence EJB 1.1Terminologies OOAD

  27. EJB 1.1 • Entity bean • Remote accessible components • Expose business data and business logic • Each entity bean represents a single independent and persistent entity in the domain • Evolve from entity objects OOAD

  28. OOAD

  29. EJB 1.1 • Home interface • Specify remotely accessible methods for the creation, location, and destruction of one type of entity bean • Evolve from lifecycle objects OOAD

  30. EJB 1.1 • Session bean • Expose high-level business logic and workflow logic that spans multiple entity beans • Translate an individual high-level request into many requests to many entity beans • Stateful or stateless • Evolve from control objects OOAD

  31. EJB 1.1 • Remote interface • Define the remotely accessible methods • The type of the returned entity objects OOAD

  32. EJB 1.1 • Implementation • A class that realizes an EntityBean or a SessionBean interfaces • Entity bean • Implementation of the business logic • Session bean • Implementation of the workflow logic OOAD

  33. EJB 1.1 • Deployment description • An XML document that describes how the entity and session beans are deployed • Location of the class file • Decisions about persistence • Decision about transactions • Security OOAD

  34. EJB 1.1 • Container • The EJB container holds entity beans and session beans • Object caching • Concurrent access • Transaction management • Persistence OOAD

  35. EJB 1.1 • Bean-managed persistence • The entity bean loads and saves its own data • Embed JDBC code within the bean’s implementation • Container-managed persistence • The developer specifies a mapping between each piece of persistent data and a field in a table in the database OOAD

  36. EJB 1.1 • Transaction boundaries • Developers specify transaction boundary in the deployment descriptor • Whether a method should join an existing transaction, start its own transaction,or execute outside of any transaction OOAD

  37. EJB 1.1Gory Details • Using EJB is infinitely better than trying to produce your own scalable remote object framework • Classes and interfaces • Remote interface, extends EJBObject • Home interface, extends EJBHome • Implementation class, implements EntityBean OOAD

  38. OOAD

  39. EJB 1.1Gory Details • Stateful session bean • Maintain a dialog with the client • Remember past requests and use them to simplify subsequent requests • Take up memory • Must be managed by the container until the session is completed • Control objects that provide a conversational workflow OOAD

  40. OOAD

  41. EJB 2.1Gory Details • Stateless session bean • Do not remember any conversational state from request to request • Container can keep a small pool of stateless session beans for use by many clients • Control objects that convert a single method into a series of smaller requests and consolidate the results OOAD

  42. OOAD

  43. EJB 1.1Gory Details • Development workflow, assuming container-managed persistence • Allocation of business data, business logic, and control logic to entity and session beans • Mapping entity data to persistent data store • Determining transaction boundaries and security OOAD

  44. EJB 1.1Strengths • Object lifecycle management • No JDBC code, reusable entity beans • Transaction management • Security • Persistence • Vendor neutrality • Portable and reuse OOAD

  45. EJB 1.1Weaknesses • Expensive application servers • BEA WebLogic • IBM WebSphere • Oracle 9i AS • Borland BES • Sun ONE Application Server • Painful code-deploy-test cycle OOAD

  46. EJB 1.1Compatible Technologies • Compatible with any kind of Java technologies OOAD

  47. EJB 1.1Cost of Adoption • Commercial-quality application servers with EJB support are expensive • Architect • Bean developer • Deployer OOAD

  48. EJB 1.1Suitability • Number and type of users • Valid choice for all types of audience • Performance and scalability • Not suitable for read-only systems • Scale well • Load balancing, clustering OOAD

  49. Sample Technology Selection • Candidates • Custom implementation based on RMI and JDBC • EJB implementation • Technology requirements • Number and type of users: general use within an organization • Performance and scalability: concurrent updates OOAD

More Related