Java Reference
In-Depth Information
8.1.1
Applying the Exposed Domain Model pattern
In a design based on this approach, the business tier consists of just the domain
model, which is called directly by the presentation tier. The presentation tier calls
domain services to update the domain objects, and repositories to query the data-
base. It gets the data to display directly from the persistent domain entities and value
objects. For example, if the presentation tier for the Place Order use case is based
on the Model-View-Controller ( MVC ) pattern [Buschmann 1996], then the servlets
(the controllers) handle requests by calling the PlaceOrderService and the Res-
taurantRepository (the model), and the JSP pages (the views) generate the
responses using domain objects, such as PendingOrder and Restaurant . Presenta-
tion tiers that use a web framework such as Struts [Husted 2002], JavaServer Faces
[Mann 2005], Spring MVC [Walls 2005], or Tap-
estry [Tapestry] would interact with the domain
model in a similar way. The controllers invoke the
services and repositories, and the view compo-
nents access the domain objects.
Because the view components can cause per-
sistent objects to be loaded as they navigate rela-
tionships, the JDO PersistenceManager or
Hibernate Session must remain open while the
presentation tier handles the request. Conse-
quently, the PersistenceManager or Session must
be managed by the presentation tier instead of by
an AOP interceptor in the business tier. The pre-
sentation tier can accomplish this by using a serv-
let filter, which is a web component that intercepts
requests before the servlets and JSP pages are
invoked. The servlet filter opens a Persistence-
Manager or Session , invokes the servlets and JSP
pages, and closes PersistenceManager or Session .
To see how this pattern works, let's consider
how to apply this pattern when writing the code
to handle the entry of the delivery information
in the Place Order use case. The user enters the
delivery information using the form shown in
figure 8.1. The application then validates the
delivery information and displays a list of avail-
able restaurants, as shown in figure 8.2.
Delivery Info
Street1:
100 Some street
Street2:
City:
Anytown
State:
CA
Zip:
94567
Date:
8/14/04
Time:
7 20 pm
Next
Figure 8.1
Delivery Info screen
Select Restaurant
Type
Description
Name
Ajanta
Indian
Fine Indian dining
XYZ Pizza
Pizza
Excellent Pizza
...
Next
Figure 8.2
Restaurant List screen
 
 
 
Search WWH ::




Custom Search