Java Reference
In-Depth Information
Fancy Foods
chocolate
department
Fancy Foods
API
Fancy Foods
API
Fancy
Foods
business
logic
Fancy Foods
foreign food
department
Fancy Foods
remote
config
Fancy Foods
persistence
Fancy Foods
web
Fancy Foods
cheese
department
Fancy Foods
persistence
Figure 10.8 The distributed Fancy Foods system includes two frameworks. The original framework
includes a new fancyfoods.remote.config bundle; the remote framework reuses some Fancy
Foods bundles and adds a new fancyfoods.department.foreign bundle.
The first thing you need is an implementation for your remote service.
10.3.1
Coding a special offer service
To simplify things, your SpecialOffer implementation is effectively identical to the
cheese department one, with a slightly different query, as shown in the following listing.
Listing 10.1
A foreign foods special offer service
public class ForeignFoodOffer implements SpecialOffer {
private Inventory inventory;
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
@Override
public String getDescription() {
return "Something exotic to spice up your weekend.";
}
@Override
public Food getOfferFood() {
List<Food> foods =
inventory.getFoodsWhoseNameContains("Foreign", 1);
Food mostStocked = foods.get(0);
return mostStocked;
}
}
Search WWH ::




Custom Search