Java Reference
In-Depth Information
stock moving. Whichever cheese has the highest stock levels should be displayed
prominently on the front page to try to spark interest. To work out the list of available
cheeses and their stock levels, we use Blueprint to wire together a SpecialOffer ser-
vice and the Inventory service, as shown in the following listing.
Listing 3.7
The Blueprint for registering a special offer with an Inventory dependency
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<service interface="fancyfoods.offers.SpecialOffer">
<bean
class="fancyfoods.department.cheese.offers.DesperateCheeseOffer">
<property
name="inventory" ref="inventory" />
</bean>
</service>
<reference id="inventory" interface="fancyfoods.food.Inventory" />
</blueprint>
With this new bundle, our system has the architecture shown in figure 3.9.
The special offer implementation takes advantage of the injected Inventory ser-
vice to work out which cheese has the highest stock levels, as shown here.
Fancy Foods
persistence
Fancy Foods
datasource
JNDI
Fancy
Foods
API
Fancy Foods
chocolate
department
Fancy Foods
business
logic
Fancy Foods
cheese
department
JNDI
Fancy Foods web
Figure 3.9
The architecture of the Fancy Foods application
Search WWH ::




Custom Search