Java Reference
In-Depth Information
Figure 23.1. The
Customer
class relies on other classes for its recommendations,
including two off-the-shelf recommendation engines.
The
LikeMyStuff
and
Rel8
engines both accept a
Customer
object and suggest
something to advertise to the customer. Both engines are configured to work for fireworks,
although
LikeMyStuff
requires a database and
Rel8
works entirely from an object model.
The code for
getRecommended()
in class
Customer
mirrors Oozinoz's advertising
policies:
public Firework getRecommended()
{
// see if we're promoting a particular firework
try
{
Properties p = new Properties();
p.load(
ClassLoader.getSystemResourceAsStream(
"config/strategy.dat"));
String promotedFireworkName =
p.getProperty("promote");
if (promotedFireworkName != null)
{
Firework f = Firework.lookup(
promotedFireworkName);
if (f != null)
{
return f;
}
}
}
catch (Exception e)
{
}