Applied Design Patterns with Java
Behavioral :: Chain of Responsibility (223) {C ch
16}
Applicability
Use the Chain
of Responsibility pattern when:
- more than one object may handle a request, and the handler
isn't known in advance. The handler should be determined automatically;
- there is a need to issue a request to one of several
objects without specifying the receiver explicitly;
- the set of objects that can handle a request should
be specified dynamically.
Structure
A typical object structure might look like this:
Participants
- Handler (HelpHandler)
defines an interface for handling requests, and optionally implements the successor link.
- ConcreteHandler (PrintButton, PrintDialog) handles requests it is responsible for, can access its successor,
and if the ConcreteHandler can handle the request, it does so; otherwise it forwards the request to its successor.
- Client initiates
the request to a ConcreteHandler object on the chain.
Catalog Behavioral Prev Next