ChainBuilder ServicePage edited by Bob Harner
Comment:
Renamed
Changes (0)
Full ContentChain of CommandOne of the most useful of the Gang Of Four Design Patterns is the command pattern. With the command pattern, a complex process is broken down into many individual steps. The steps are the commands in the command pattern. A key part of this is that the commands are expected to implement some common interface. The commands are carefully arrainged into a specific order. The process operates by working down the list of commands. Each command is given a chance to operate. A command can terminate the process either by throwing an exception, or by returning true. The return type of the command method does not have to be boolean: For object types, any non-null value short-circuits the process. For numeric type, any non-zero value. For void methods, only throwing an exception will short circuit the process. Often, the command interface consists of a single method. When the command interface has multiple methods, each can be thought of as its own chain. This is a useful pattern because it makes it very easy to extend a given process, simply by providing new commands and specifying where they fit into the overall process. Most often chain of command is combined with an ordered configuration to define what the list of commands are (and in what order they should execute). ChainBuilder ServiceBecause this pattern is used so often inside Tapestry, a built-in service exists to create implementations of the pattern as needed. The ChainBuilder service takes care of all the work: public interface ChainBuilder { <T> T build(Class<T> commandInterface, List<T> commands); }
Change Notification Preferences
View Online
|
View Changes
|