Patterns and Frameworks for Managing Dynamic Views in





















- Slides: 21

Patterns and Frameworks for Managing Dynamic Views in Web Applications Author: Daniel Archambault Supervisor: Harold Streeter

Overview n n n Scope of the problem of managing dynamic views in web application Motivation behind providing better solution for managing dynamic views in web application Patterns and Frameworks already in use New Pattern and Framework proposed Future work

Web Application Development Problems n There are several problems being actively researched in web application development, such as: n n n Managing Dynamic View: determine which view to display and its content with consistent information Authentication: identify users of a system and decide what privileges to provide to specific users Error Handling: determining accurately source of error, reporting it appropriately and recovering from it

Problem of Managing Dynamic View in Web Application n View and Content of web pages are becoming increasingly complex n n Need to decouple the work of the web designer creating views from the programmers providing the content Need to provide improved web application development framework to facilitate: n n View’s components arrangement and reuse Interconnection between view components state and input handling with object defining application’s behaviors

Motivation n Generally in commerce: n n n competition is reducing profit margins cost of running and maintaining increasingly complex system increases Very important to minimize costs to avoid losing money profit cost time

Motivation cont’d n Achieving desired set of Quality attributes n n n n Modifiability Security Performance Reliability Availability Usability Patterns and Frameworks facilitate building, maintaining and expanding complex web application by focusing on such quality attributes

Relationship between Patterns and Frameworks Patterns: Frameworks: • Model-View Controller (MVC) • J 2 EE Blue. Prints Web Application Framework(WAF) • Model 1 • Model 2 • Patterns within MVC • Front Controller • Mediator • Command • Composite View • Observer • … Building Blocks of • Apache Struts • Apache Turbine • Barracuda • Hammock • Source. Forge Web. Work • BEA Web. Logic • IBM Web. Sphere • …

Model-View-Controller Pattern n Model-View-Controller (MVC) Pattern n Well established pattern for development of interactive application Increasingly popular in web application development Benefits n n n Separates design concerns (control, presentation, data persistence and behavior) Decreases code duplication Centralizes control Improves application modifiability Helps construct architecture that facilitates managing dynamic views

Model-View-Controller Pattern Structure Controller • Defines application behavior • Maps user actions to model updates View Selection • Selects view for response State Change User Actions View State Query Model • Renders the models • Encapsulates application state • Requests updates from models • Responds to state queries • Sends user actions to controller • Exposes application functionality • Allows controller to select view Events: Change Notification • Notifies views of changes Method Invocations:

MVC Model 1 Pattern n n Application control is decentralized (current page determines next page to be displayed) Each JSP page processes its own inputs (parameters from GET or POST) Request Browser Response JSP Java. Bean Application Server Enterprise Servers/ Data Sources

MVC Model 2 Pattern n The only difference with Model 1 is the addition of a controller servlet n n Dispatch requests from the client tier Selects views Response Request Browser Servlet (Controller) instantiates Application Server JSP (View) Java. Bean (Model) Enterprise Servers/ Data Sources

J 2 EE Blue. Prints Web Application Framework (WAF) n WAF is a good starting point for learning about the principles of MVC Model 2 based framework design and usage in web application n n It is used as the infrastructure of some sample J 2 EE applications provided by Sun Demonstrates the mechanism and effective use of a Web-tier framework in an application design WAF is suitable for small and non-critical application Features n n n Front Controller servlet Abstract action class for Web-tier actions Templating service Generic custom tags Internationalization support

Apache Struts Framework n Struts is also based on the MVC Model 2 pattern, but is more powerful than WAF n n Industrial-strength framework Suitable for large application Struts is not a “standard” for which J 2 EE product providers can reliably create tools Struts provides more features than WAF n n Web forms with validation Automatic population of server-side Java. Beans Utility classes for XML Richer set of custom tags the ones offered by WAF

Apache Turbine Framework n Turbine is similar to Struts, but has richer set of features for managing dynamic view, such as: n n n Turbine also have a broader scope than struts, providing: n n Integrates with other template engine than JSP, such as Cocoon, Web. Macro, Free. Marker and Velocity Caching Services (speeds up dynamic web applications by providing a means to manage cached data of various dynamic natures ) Integration with Object Relational Mapping tools capability Job scheduler Localization services It is based on “Model 2 + 1” which is very similar to Model 2 (main difference is the way the actions are used)

Enhydra Barracuda Framework n n Barracuda framework is a combination of MVC and Component frameworks It is more scalable than Struts, since it supports 3 different approach to content generation (accommodate application development with different levels of complexity): n n n Simple Servlets Template Engines (JSP, Tea. Servlet, Webmacro, Freemarker, Velocity) Document Object Model (DOM) Manipulation It provides better component composition and reuse than using Turbine or Struts Barracuda is still not a “standard” for which J 2 EE product providers can reliably create tools

New Framework Proposed: Java. Server Faces n n n Java. Server Faces intends to handle all of the complexity of managing the user interface on the server Definition in progress by the Java Specification Request JSR 127 n To establish a standard API for creating Java web application GUIs n To eliminate the need for developers of creating and maintaining web application GUI infrastructure n To help bridge the gap between conventional GUI toolkit developers and web-based GUI developers Javer. Server Faces will provide a standard GUI component framework which can be leveraged by J 2 EE development tools providers

New Pattern Proposed: Active View n n n Active View is a new pattern in the area of web application business layer Intent: Manage a Web active (dynamic) view Forces: n n n Increase in demand for dynamic page content Requirement to update content with consistent information Need to develop a specific powerful client by using a particular protocol to support communication between client and server. n When data value changes in database, the runtime system produces a particular signal over the net, and upon receiving the signal the client update its view.

New Pattern Proposed: Active View cont’d n Solution: n The Active View pattern provides a solution to this problem by refocusing the Observer pattern in a Web architecture n n Defines an easy method to develop an application Renders the front-end receptive to business logic’s signal Increases the independence among objects, allowing the subject to disregard the number of interested objects The communication between the subservlet and observlet could be developed using standard potocol such as Java RMI

New Pattern Proposed: Active View structure <<Httpservlet>> Subject Observer 0. . * #do. Get() #do. Post() Observlet +attach(observer) +detach(observer) +notify() +update() * 1 Subservlet 1. . * Trigger +Send. Event()

Future Work n n n Study more in-depth the Active View pattern Explore integrating the Active View pattern with other patterns Provide a reference implementation of the Active View pattern as a proof of concept

References n n n Patterns for Web applications, Diego Bonura, Rosario Culmone, Emanuela Merilli, July 2002, ACM 1 -58113 -556 -4/02/0700 Java. Server Faces Technology http: //java. sun. com/j 2 ee/javaserverfaces/ Java. Server Faces - JSR 127 http: //jcp. org/en/jsr/detail? id=127 Understanding Java. Server Pages Model 2 Architecture -http: //www. javaworld. com/javaworld/jw-12 -1999/jw-12 -ssj-jspmvc. html The Problems with JSP -- http: //www. servlets. com/soapbox/problems-jsp. html The Apache Jakarta Project -- http: //jakarta. apache. org/ Enhydra Barracuda http: //barracuda. enhydra. org Design Patterns: From Analysis to Implementation, Net Objectives, 2002 Design Pattern for Web Programming - Do you need MVC? , Al Williams, June 2002, Internet Strategies for Technology Leaders The Role of Patterns in Enterprise Architecture http: //www. ftech. co. uk/~honeyg/articles/pda. htm Designing Enterprise Applications with the J 2 EETM Platform, Second Edition http: //www. ftech. co. uk/~honeyg/articles/pda. htm