Database Reference
In-Depth Information
Figure 12-6.
The Java sample application home page
Controller and Service Layers
In order to provide some common objects and methods at the controller layer, all of the action controllers in the
sample application extend a parent controller called
GraphStoryAction
. The
GraphStoryAction controller
provides
access to the
GraphStory
bean and the
GraphStoryDAO
service.
The
GraphStory
bean encapsulates the domain objects for the sample application and is primarily used for
convenience. This object will allow domain objects to be sent to the service layer and returned—in some cases—with
helper objects and properties, such as form and data validation messages to help users.
The
GraphStoryDAO
service provides access to each of the individual service classes that support persistence and
other service-level operations on each of the domain objects. For example, if an exception is raised in the service layer,
such as a when attempting to create a User that matches an existing User's username, then the
GraphStory
object can
be returned with message information, such as an error message, which can then be used to determine the next part
of the application flow as well as return messages to the view.