Java Reference
In-Depth Information
7.5 Implementing a result factory
The third step in the process of implementing a
POJO
façade is writing the result
factory that is called by the
POJO
façade to detach the domain objects that it
returns to the presentation tier. In a
JDO
application, the result factory must call
the
JDO
detachment
API
s, which return detached copies of the persistent objects.
In a Hibernate application, the result factory simply has to make sure the
required objects are loaded because detachment is automatic. In both cases, the
POJO
façade must make sure that the object graph contains all of the objects
required by the presentation tier.
The set of objects that need to be detached is primarily determined by the data
that is displayed by the presentation tier. For example, in the Place Order use case,
the Order page displays data from several objects, including the delivery information
from the
PendingOrder
, the quantities from the pending order's line items, and the
menu items from the selected restaurant. Consequently, the
PlaceOrderFacade
must
return an object graph containing the
PendingOrder
, its line items, its restaurant, and
its restaurant's menu items. Figure 7.7 shows the object graph starting from the
PendingOrder
that needs to be returned to the presentation tier.
:Pending
Order
:Coupon
:OpeningHours
:PendingOrder
Lineitem
:Restaurant
:ServiceArea
:MenuItem
Figure 7.7
The object graph reachable from
PendingOrder
Search WWH ::
Custom Search