&雪扇 Example 102 UNIVE 6 aSaveDlalog handler aPrintButton anAppllcation handler handler aPrintDlalog handler anOKButton handler specific aPrintButton aPrintDialog anApplication general HandleHelp0 HandleHelp( Institute of Computer Software 2022-2-27 Nanjing University
Example 2022-2-27 Institute of Computer Software Nanjing University 6
1002 Applicability 口有多个对象可以处理一个请求,哪个对象处理 该请求则在运行时刻确定 ▣在不明确指定接收者的情况下,向多个对象中 的一个提交一个请求 口可处理一个请求的对象集合应被动态制定 Institute of Computer Software 2022-2-27 Nanjing University
Applicability 有多个对象可以处理一个请求,哪个对象处理 该请求则在运行时刻确定 在不明确指定接收者的情况下,向多个对象中 的一个提交一个请求 可处理一个请求的对象集合应被动态制定 2022-2-27 Institute of Computer Software Nanjing University 7
条 Structure 1002 UNIVER 8 successor Cllent Handler HandleRequest( ConcreteHandler1 ConcreteHandler2 HandleRequest() HandleRequest( Institute of Computer Software 2022-2-27 Nanjing University
Structure 2022-2-27 Institute of Computer Software Nanjing University 8
&扇 Participants UNIVE 9 Handler 口定义一个处理请求的接口 口(可选)实现后继链 ConcreteHandler 口处理它所负责的请求 口可访问它的后继者 口如果可处理该请求,就处理之;否则将该请求转发给它的后 继者 Client 口提交请求 Institute of Computer Software 2022-2-27 Nanjing University
Participants Handler 定义一个处理请求的接口 (可选)实现后继链 ConcreteHandler 处理它所负责的请求 可访问它的后继者 如果可处理该请求,就处理之;否则将该请求转发给它的后 继者 Client 提交请求 2022-2-27 Institute of Computer Software Nanjing University 9
&扇 Collaboration 1002 UNIVE 10 当Client提交一个请求时,请求沿链传递直至有 一个ConcreteHandler对象负责处理它 aCllent aConcreteHandler aHandler aConcreteHandler successor successor Sample Code Institute of Computer Software 2022-2-27 Nanjing University
Collaboration 当Client提交一个请求时,请求沿链传递直至有 一个ConcreteHandler对象负责处理它 2022-2-27 Institute of Computer Software Nanjing University 10 Sample Code