Java Reference
In-Depth Information
10.4 Assembling the components
A façade uses several components, including the result factory, the domain ser-
vices, and repositories. These components can in turn reference other compo-
nents as well as infrastructure objects such as the EntityManager . For example,
the PlaceOrderFacade directly and indirectly requires the components shown in
figure 10.3.
The PlaceOrderFacade requires the PlaceOrderService , RestaurantReposi-
tory , and the PlaceOrderResultFactory . The PlaceOrderService requires reposi-
tories such as the PendingOrderRepository and the RestaurantRepository . The
repositories must be configured with the EntityManager .
At runtime, the application must instantiate these components and wire them
together. So far, the examples in this topic do this using a Spring bean factory.
The bean factory uses dependency injection to wire the components together.
Each component is passed the components that it needs as either constructor
arguments or setter method arguments. Dependency injection is valuable because
it eliminates code that looks up dependencies and thus reduces the coupling
between components.
PlaceOrder
Façade
PlaceOrder
Service
PlaceOrder
ResultFactory
Restaurant
Repository
PendingOrder
Repository
EntityManager
Figure 10.3
The PlaceOrderFacade and its dependencies
 
 
Search WWH ::




Custom Search