Java Reference
In-Depth Information
Figure 3-8.
Abstract controller class diagram
As shown in Figure 3-8, the
AbstractController
class implements the
Controller
interface and defines a well-defined workflow that can be used by the subclasses. This
class implements the template method design pattern (GOF) to define a fixed workflow
with suitable extension hooks to alter the workflow. The sequence diagram shown in
Figure 3-9 illustrates the workflow defined by this class.
Figure 3-9.
Abstract controller sequence diagram
The handler adapter invokes the
handleRequest
method to trigger the workflow. The
checkAndPrepare
method is then invoked on the superclass
WebContentGenerator
to per-
form the following activities:
1.
Inspect whether the HTTP method for this request is supported. This can be used
to block unwanted HTTP method requests such as
DELETE
. It can be used for
access to some read-only resources such as help pages by supporting
GET
requests.
2.
Check whether an HTTP session is already started. This is can be useful if the
application needs some data already stored in the session before carrying out
further processing.
3.
Set hints for the clients with the cache duration of the final response sent by the
dispatcher servlet.


