Java Reference
In-Depth Information
You'll also reuse the trick for populating the database, as follows.
Listing 10.2
Populating the foreign food database
public class InventoryPopulater {
private Inventory inventory;
public void setInventory(Inventory inventory) {
this.inventory = inventory;
public void populate() {
boolean isInventoryPopulated = (inventory.getFoodCount() > 0);
if (!isInventoryPopulated) {
inventory.createFood("Foreign Sushi", 3.45, 10);
inventory.createFood("Foreign Borscht", 1.81, 15);
Once again, you can use Blueprint to glue everything together, as shown in the follow-
ing listing.
Listing 10.3
Exposing your remote service
<?xml version="1.0" encoding="UTF-8"?>
<service interface="fancyfoods.offers.SpecialOffer">
Mark your service
<entry key="service.exported.interfaces"
<bean class="fancyfoods.department.foreign.ForeignFoodOffer">
<property name="inventory" ref="inventory"/>
<reference id="inventory" interface=""/>
<bean class="fancyfoods.department.foreign.InventoryPopul ate r"
activation="eager" init-method="populate">
<property name="inventory" ref="inventory"/>
Having built your bundle, you can deploy it into your test environment along with the
API , datasource, and persistence bundles. You can also see your remote service regis-
tered in the Service Registry (see figure 10.9).
Eagerly populate
Search WWH ::

Custom Search