Chapter 4: Struts-Based Application Architecture


Overview

For enterprise software development, we constantly strive to use standards-based platforms and software. Standards-based software offers the flexibility of developing solutions that are interoperable, use industry best practices, and provide the option of selecting the infrastructure from any vendor without the risk of breaking the architecture. JSP, Servlet, and EJB specifications, among others, have enabled the programmers to declaratively obtain system-level services from the implementations of these standards; the result is that the developers have been able to experience large productivity gains by focusing on business problems rather than trying to deal with system-level services such as transaction, security, and resource management.

Standards-based development factors common system functionality into core platform services that use proven design patterns and best practices; this creates a foundation framework on which custom functionality can be built. However, one area where a standard was not prescribed, for an infrastructure-level service, was the mapping of client-side actions (or events) to server-side method invocation on business components using the HTTP protocol, the corresponding navigation semantics, and HTML forms processing. The challenge of assimilating a request/ response-based HTTP protocol in an event-based MVC (Model-View-Controller) pattern has resulted in another industry of solution providers. During the early years of J2EE, an enterprise application architect who was dealing with large projects involving a large number of Web pages was expected to roll his or her own version of a presentation framework that implemented an MVC-like architectural style; as you will appreciate, this was no small feat to accomplish. The more recent JavaServer Faces standard addresses issues such as representing UI components and their state management, defining navigational semantics, event handling, forms validation, internalization support, and so on. However, the Jarkarta open source project ‘Struts’ has already achieved the mind share and acceptance from enterprise architects as a viable MVC-based presentation framework that supports much of the functionality offered by JavaServer Faces. At the time of this writing, the expectation is that Struts-based implementations will use JavaServer Faces components for component-level functionality within a page, but continue to use the their own application model for dealing with higher level functionality, such as forms and actions. For more information on JavaServer Faces, refer to http://java.sun.com/j2ee/javaserverfaces. The future direction of Struts is to transition over to JavaServer Pages Standard Tag Library (JSTL) and JavaServer Faces tags.

Another framework that is worth mentioning is the XMLC-based Barracuda Presentation Framework. XMLC is an XML compiler that converts document templates, including HTML, cHTML, WML, XHTML, and XML, into Java objects that implement the DOM interface. Java programs can manipulate the DOM representations of these documents on the server side by merging the state information from the application's model into the DOM representations. Once the DOM is modified, it can be serialized into the source document type or other XML-compliant format that represents the response; this enables a high degree of separation between the presentation and the business logic. A web production engineer (a.k.a. form designer), therefore, works completely independent of the application engineer, who depends only on finding and replacing tags with certain ID and class attributes set by the production engineer; XMLC generates access methods for these special tags, and these access methods serve as a formal interface between production engineer and the application engineer. You can get more information on Barracuda by visiting http://www.enhydra.org.

In this chapter, we define the requirements of a robust presentation framework and simultaneously discuss how these requirements are implemented in the Struts framework. We also explore the design patterns implemented by Struts and the semantics of the controller and associated helper components, and we examine various Struts-related configuration resources; this knowledge will be useful when designing components that will interact with the framework, and when there is a need for extending the framework for accommodating special needs of a project. Struts-based application architecture with practical examples will be covered in Chapter 5 where we have identified several Struts-related patterns that can be used as implementation templates in implementing complex behaviors. This chapter cites several examples, where appropriate, from Chapter 5. We cover "under the hood" semantics of Struts to gain a better understanding of how Struts is architectured, and what possibilities exist should you decide to extend the framework; as such, only limited coverage of examples have been provided in this chapter, with the rest of the discussion deferred to Chapter 5.




Practical J2ee Application Architecture
Practical J2EE Application Architecture
ISBN: 0072227117
EAN: 2147483647
Year: 2003
Pages: 111
Authors: Nadir Gulzar

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net