Java Reference
In-Depth Information
public void shutDown()
{
if (inProcess())
{
stopProcessing();
markMoldIncomplete(currentMoldID);
}
usherInputMolds();
dischargePaste();
flush();
}
You might find it inconvenient to subclass AsterStarPress with a class that you have to
move to the star press's on-board computer. Suppose that you ask the developers at Aster to
provide the hook in a different way, using the C OMMAND pattern. Figure 24.2 shows a Hook
interface that the AsterStarPress class can use, letting you parameterize the star press
code at runtime.
Figure 24.2. A class can provide a hook—a way to insert custom code—by calling
a supplied object's execute() command at a specific point in a procedure.
The AsterStarPress class initially sets its hook to be a NullHook object.
The execute() method of NullHook does nothing. You can supply your own
implementation of Hook for the shutDown() method to call. The shutDown() method
now relies on this hook, executing it and passing it the AsterStarPress object at the right
moment:
public void shutDown()
{
if (inProcess())
{
stopProcessing();
markMoldIncompleteHook.execute(this);
}
usherInputMolds();
Search WWH ::




Custom Search