Chapter 13. Multitiered architectures
In this chapter:
- The three-tiered service architecture
- Dependency injection and why it matters
- Creating a layered application using Wicket, Spring, and Hibernate
So far, we’ve looked at the individual nuts and bolts of Wicket through the use of simple examples. We’ve developed a virtual cheese store with functionality to browse through a catalogue, place orders, view discounts, and edit those discounts. The big thing missing from those examples is what you’d almost certainly have in real life: a database that stores the orders, discounts, and so on.
In this chapter, we’ll look at a common pattern of organizing source code into layers. We’ll use the Spring framework to manage one of these layers—the business layer—and we’ll use Hibernate as a tool to access the database in a transparent (object-oriented) way. In the fashion of the last five chapters, we’ll further build on the cheese discounts list.
The architectural pattern of dividing your application into tiers (layers) with their own responsibilities as we’ll describe is commonly used for creating web applications and is often called a three-tiered service architecture. Schematically, it looks like figure 13.1.
The presentation tier takes care of the UI. All the pages, components, models, and behaviors that are part of an application logically belong to this tier.