|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
Handler<R> | A handler can handle a given type of request by taking appropriate action or by forwarding the request to the next handler in the current chain of handlers. |
HandlerChain<R> | A handler chain is an ordered list of handlers
that will be passed a request in turn until the first applicable
handler can handle it. |
HandlerLink<R> | A handler link represents a connection to the next
handler in a given handler chain. |
Class Summary | |
---|---|
AbstractHandlerChain<R> | An abstract handler chain implements the basic
traits of the HandlerChain interface. |
CharacterHandler | An abstract character handler implements the basic traits
of handlers handling Character objects. |
LetterCaseHandler | A letter case handler is a handler that can handle
letter characters in either upper or lower
case only. |
LetterHandler | A letter handler is a handler that can handle
letter characters. |
Main | Chain of Responsibility tests. |
StandardHandlerChain<R> | A standard handler chain is the standard implementation
of the HandlerChain interface. |
SymbolHandler | A symbol handler is a handler that can handle
symbol characters. |
WeakHandlerChain<R> | A weak handler chain is a thread-safe handler chain storing
registered handlers as weak references. |
WhitespaceHandler | A whitespace handler is a handler that can handle
whitespace characters. |
Implementations and examples of the Chain of Responsibility design pattern [Gamma95, p.223].
Intent:
Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
Handler
interface, and the ConcreteHandler participant by any
Handler
implementation. Several handler implementations
are defined in this package, all sub-classes of the
CharacterHandler
class, each thus handling Character
objects. Examples include SymbolHandler
and LetterCaseHandler
.
The Client participant is the test application, i.e. the
Main
class.
Implementation notes:
This implementation differs from the canonical "Gang of Four"
implementation in that it makes the handler chain explicit using
the HandlerChain
interface. Here, handlers need not store the successor in the chain locally,
and can participate in several chains concurrently. The link to the
next handler is supplied at execution time using a
HandlerLink
.
Two explicit HandlerChain
implementations have been made,
namely StandardHandlerChain
and WeakHandlerChain
. The first
is a simple implementation that is not thread-safe, while the latter is
thread-safe and stores handlers as weak references.
|
Gunni Rode / rode.dk | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |