1, responsibility Chain mode: so that multiple objects have the opportunity to process the request, thus avoiding the coupling between the sender and the recipient of the request. Link this object to a chain and pass the request along this chain to instruct an object to handle it. 2, Advantages: (1), when the customer submits an application, the request is passed along the chain until there is an object responsible for processing its location. At the client there is no need to know who is doing the processing. (2), simplifying the connection of objects, they only need to maintain a reference to the subsequent successor, and do not need to maintain all of its candidate recipients of the reference. (3), can add or modify the structure of processing a request at any time. Increased flexibility in the role of the object solitaire. 3, note: A request is most likely to the end of the chain is not processed, or because there is no correct configuration to be processed. This must be considered at design time. 4. Composition:(1), abstract Processor (Handler) role: Defines an interface for processing requests. If necessary, the interface can define a method to set and return a reference to the home. This role is typically implemented by a Java abstract class or Java interface. The aggregation relationship of the handler class gives a reference to the sub-class, and the abstract Method HandleRequest () regulates the operation of the sub-class processing request. (2), the specific processor (Concretehandler) role: When the specific processor receives the request, you can choose to dispose of the request, or pass the request to the other person. As the specific processor holds references to the homes, the specific processor can access the homes if necessary.
Responsibility chain Model