Origin: |
GoF 95 |
Reason: |
To issue a command to an object that may execute it or
send it to another object for execution.
|
Synopsis: |
Different commands are executed by different objects in a chain.
Objects early in the chain pass on commands they should not execute.
|
Example: |
Consider a security system.
In a system with only a few sensors, an alarm is handled locally,
e.g., ring a bell. In a large system, an alarm is reported
to a remote control station.
|
Solution: |
CommandSender |
Calls postCommand of the first object in the chain.
It is the client of the chain.
|
CommandHandler |
Superclass of all the ConcreteCommandHandlers
in a chain of responsibility.
Defines methods postCommand
that manages the chaining of commands, and
handleCommand that returns whether
a command was completely executed.
Has link to next CommandHandler in the chain.
|
ConcreteCommandHandleri |
These classes override handleCommand, but not
postCommand.
|
|
See also: |
Composite
(the chain is a composite object)
Command
(may use it for representing commands)
|