|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Therefore, application developers would benefit from an easily modifiable and reusable Dispatcher strategy. In this article, you'll find techniques to develop a dynamic, configurable workflow tool designed to ease workflow development and maintenance, as well as make the user's experience pleasant.
This article first introduces the Dispatcher pattern, as well as ancillary patterns such as Front Controller and Service to Worker. The article then details an implementation strategy for a reusable dispatcher. It concludes with an example illustrating how a dispatcher can help in a real-world business situation.
Note: This article features example source code.
The Dispatcher design pattern separates view responsibilities from business and system logic, and separates Web production and software development teams. The Dispatcher pattern can meet the following needs:
The Dispatcher pattern therefore becomes responsible for view management and navigation. It is best employed when outside resources choose the view. For example, the Service-to-Worker pattern collects data before the dispatcher comes into use so that the dispatcher can choose the view based on the data collected. That scenario contrasts with the typical dispatcher, which chooses the view based on state information; in such a case, the view decides what data to pull.
Developers most commonly employ the Dispatcher pattern with a request-handling controller. You could implement the controller
with a servlet, a JavaServer Page (JSP), or a component that delegates dispatch responsibilities to the Dispatcher object. Figure 1's sequence diagram demonstrates the process.
Figure 1. The Dispatcher pattern. (Source: Sun Microsystems Inc.) Click on thumbnail to view full-size image.
The sequence diagram in Figure 2 illustrates the Service-to-Worker pattern. Notice how it collects the data before the dispatcher performs its tasks.
Figure 2. The Service-to-Worker pattern. (Source: Sun Microsystems Inc.) Click on thumbnail to view full-size image.
You'll find many different strategies for implementing a dispatcher. Sun's "J2EE Patterns Catalog," proposes several:
Next, let's look at a dispatcher implemented using XML and XSL, in which XSL determines the view. The solution applies XSL to an XML representation of the current session information, along with additional state information such as the current view, the user's security role, and whatever other information might be handy.