6.2. The Command Pattern

The second pattern we will explore is the command pattern. The command pattern is simple; to implement it, an object needs to implement the following interface:

public interface Command {
  public void execute();
}

In other words, any object that implements the command pattern provides an execute method. What the execute method does depends on the context and application in which it is being used. The important point is, if you have an object that implements the command pattern, you know you can invoke its execute method. While this pattern is simple, its power stems from our ability to drop an object into a space and have another process pick it up and invoke methods on it, even if the remote process has never seen the ...

Get JavaSpaces™ Principles, Patterns, and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.