140 likes | 144 Vues
Designing J2EE Applications. Objectives. After completing this lesson, you should be able to do the following: Describe the various Java 2, Enterprise Edition (J2EE) patterns Use the Model View Controller (MVC) architecture to design more efficient and maintainable applications
E N D
Objectives • After completing this lesson, you should be able to do the following: • Describe the various Java 2, Enterprise Edition (J2EE) patterns • Use the Model View Controller (MVC) architecture to design more efficient and maintainable applications • Identify sample architectures and their merits and demerits
Realizing J2EE Benefits • To leverage the full benefits of J2EE, you must design applications that are: • Portable: You should be able to redeploy the J2EE applications to different servers, databases, and so on. • Scalable: Web applications should be able to handle large numbers of users. • Maintainable: A minimum amount of coding should be necessary for a new business rule. • Reusable: A class that processes credit cards should be reused by multiple applications. • Simple: The business need should be solved with the least amount of complexity.
J2EE Issues • It is important to follow certain guidelines for the design and development of any new technology: • Implement generally accepted design patterns and architectures. • Focus on real business needs rather than simply adopting new technology. • Employ the simplest technology to solve a business problem.
J2EE Design Patterns • Recurring application development issues have led to the acceptance of design patterns. The generally accepted design patterns include (but are not limited to) the following: • Presentation-tier patterns • Intercepting filter • Controller servlet • Business-tier patterns • Business delegate • Transfer object
Implementing Design Patterns by Using MVC • MVC is a framework that separately identifies the components of an application as: • Business functionality (Model) • Presentation (View) • Control logic (Controller) View Controller Model
The Model • The model represents the enterprise data and business rules, handling access and updates. • You can simplify the model by using two mechanisms called “façade class” and “command pattern.” • A façade encapsulates and hides the complexity, and coordinates the operations between cooperating classes. • A command pattern encapsulates each application function in a separate class. • The model is often implemented as EJBs.
The View • The view focuses on presentation and is responsible for maintaining consistency between data presentation and model changes. It enables: • Presentation to be changed without alteringprogramming logic • Development by Web page authors having only visual design skills • The view is commonly implemented as JSPs.
The Controller • The controller provides interaction with the client, serving as a “glue” between the model and the view. • The controller: • Interprets user requests, and controls business objects to fulfill these requests • Removes navigation coding from the view • Can be implemented in the client, Web, or EJB tier or in a combination of these tiers • The controller is usually implemented as a servlet.
MVC in Oracle Application Server 10g Containers for J2EE View Controller Model Selectedview Methodinvocation Returnresult JSP Servlet Enterprise JavaBeans HTTPrequest HTTPresponse Browser
Designing J2EE Applications • Use the following techniques when designing J2EE applications: • Use case analysis: Identify the operations that each component will perform. • Decide how to distribute application functionality across tiers: • A JSP or servlet can access the database by using JDBC, without interfacing with the EJB tier. • Creating EJBs relieves the developer from the task of managing transactions.
Vendor Flow Diagram: Example Receiveorderstatus Customer Administrator Placeorders Log in Fill orders Browseproducts Update inventories
Summary • In this lesson, you should have learned how to: • Consider generally accepted patterns when designing J2EE applications • Identify the model, the view, and the controller components for a J2EE application
Practice 3-1: Overview • This practice covers using J2EE design patterns and the MVC architecture to identify components for a proposed application.