Example: A Jakarta Struts SAD - UML

Struts is a popular open source Java technology framework for handling Web requests and page - flow coordination. In this example, partial SAD, I wish to illustrate a logical view in more detail.

Software Architecture Document Jakarta Struts Framework

Architectural Representation

Architectural Factors

Architectural Decisions

Logical View

The Struts framework - and subsystems built with it - reside primarily in the Ul layer of a web application. Figure illustrates noteworthy layers and packages with a UML package diagram.

Figure 1. Noteworthy layers and packages related to Struts

There is a distinction between pure Ul layer responsibilities, that encompass creating the content and pages for display, vs. what is sometimes called the application control layer - the layer of components that is responsible for deciding the flow of control, and directing the presentation layer to display something. In common use, web presentation frameworks usually imply the inclusion of application control responsibilities, which is also true of Struts, as it requires developers to create subclasses of the Struts Action class that are responsible for flow control decisions.

Architectural Patterns

The Struts architecture is based on the Model - View - Controller (MVC) pattern; specifically, the web systems variant where the component roles are:

Controller :- a multithreaded singleton Facade - like object responsible for receiving and delegating HTTP requests, and by collaboration with other objects, controlling the flow of the application.

View :- components responsible for generating display content (e.g., HTML).

Model :- components responsible for domain logic and state.

Struts adoption of MVC provides the architectural foundation to achieve a separation of concerns related to flow control, display content generation (and formatting), and application logic - in this case through modularization into separate component groups that specialize by cohesively related responsibilities.

The specific MVC roles mapped to Struts components is illustrated in the UML class diagram in Figure.

Figure 2.MVC roles in Struts

Related Patterns

The ActionServlet acts as a Facade onto the presentation layer. And although not a classic Mediator that receives and mediates messaging between other decoupled objects, it is similar, because an Action object returns an ActionForward object to the ActionServlet, which is used to direct the next step.

The Struts ActionServlet and Action design also illustrates the Command Processor pattern, a variant of the GoF Command design pattern. The ActionServlet plays the role of Command Processor, receiving requests and mapping them to Action (Command) objects that execute requests.

Struts demonstrates the Front Controller and Business Delegate patterns. The ActionServlet is the Front Controller, or initial point of contact for handling requests. The Action objects are Business Delegates - abstractions that delegate to the "business" or domain layer of services.

The Action objects also play the role of Adapters, adapting the framework calls to the interface of the domain layer objects.

As illustrated in the Figure, the ActionServlet implements the Template Method pattern: process is the template, and the processXXX are the hook methods.

Framework Hotspots

Figure 3.Struts framework hotspots

Key to using a framework is knowing its hotspots - the variation points in the framework where the developer can parameterize or "plug in" applications - specific varying behavior, through techniques such as subclassing, composition based on interfaces, and declarative constraints or mappings usually externalized in configuration files. Figure illustrates key Struts hotspots, which use subclassing and declarative mappings, typical of whitebox framework designs.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

UML Topics