140 likes | 165 Views
Learn the benefits and best practices of using Enterprise Java Beans Model 2 for building scalable and robust solutions, managing transactions, and handling concurrency in enterprise applications. Find out when to use J2EE Model 2, the difference between Java Beans and Enterprise Java Beans, and the types of EJBs available. Explore session beans for controlling business logic, entity beans for data access, and message beans for communication. Discover how EJB pooling, client-server architecture, and clustering can enhance your application's performance and scalability.
E N D
Model OneArchitecture Database Model 1 J2EE – Web View Model/View/Controller WebServer HTTP Request Model View Control HTTP Response
Model OneArchitecture Database Model 1 J2EE – Other Views Model/View/Controller REWRITE!!!
Model 2 J2EE – Other Views Model TwoArchitecture Control Model View Session Bean EntityBean REWRITE!!!
Model 2 with J2EE EJB’s Model Two Architecture Web Container EJB Container View Control Model WebServer Request Handler HTTP Request Entity EJB Session EJB Servlet JavaBean JavaBean Build View HTTP Response <<forward>> JSP page
EJB Benefits • Flexibility, Scalability and Adaptability • Design based on best practices (design patterns) • Facilitates communication (common framework) • Reusability • More robust solutions and saves development time • Security • Transaction management • Concurrency control • Resource management • Persistence • Operating environment handling • Error handling
When should I Use J2EE Model 2? • Multiple apps share common data repository • Must support transactions • You need fine grained security (functional level) • High Scalability • High Availability • Must support multiple clients
Java Beans vs. Enterprise Java Beans Java Beans Enterprise Java Beans • General purpose component • Highly specialized business logic components • Collection of classes based on patterns • A single class • Executed and used anywhere • Executed only in an enterprise container
Three types of EJBs • Session beans – control/business logic and transaction management (Control) • Entity beans – to access data objects (database, file system, etc.) (Model) • Message beans – to communicate with other applications
Client Client EJB2 Servlet/JSP Applet EJB2 Client Client EJB2 B-to-B Swing App EJB2 The EJB Pool EJB2 EJB2 EJB1 EJBContainer EJB Pool Server
Client Client Servlet/JSP Applet EJB2 EJB3 Client Client EJB5 EJB4 B-to-B Swing App EJB2 Swapping in EJB Pool EJB1 EJB2 EJB2 EJBContainer EJB3 EJB3 EJB Pool EJB4 EJB4 EJB5 EJB5 Server
Client Client EJB2 Servlet/JSP Applet EJB2 Client Client EJB3 B-to-B Swing App ClusteredServers EJB2 EJB4 Clustering of EJB Servers EJB3 EJB2 EJB4
Deploy Model 2 with EJBs View Layer Control & Model Layer