最病 Exampl e 6 asaveDlalog handler aPrntButton anApplleatilon handler handler aPrintDlalog handler anoKButton handler specific aPrintButton aPrintDialog anApplication HandleHelpO HandleHelpo Institute of Computer Software 2021/215 Nanjing University
Example 2021/2/5 Institute of Computer Software Nanjing University 6
最病 E Applicability 7 口有多个对象可以处理一个请求,哪个对象处理 该请求则在运行时刻确定 口在不明确指定接收者的情况下,向多个对象中 的一个提交一个请求 口可处理一个请求的对象集合应被动态制定 Institute of Computer Software 2021/215 Nanjing University
Applicability 有多个对象可以处理一个请求,哪个对象处理 该请求则在运行时刻确定 在不明确指定接收者的情况下,向多个对象中 的一个提交一个请求 可处理一个请求的对象集合应被动态制定 2021/2/5 Institute of Computer Software Nanjing University 7
最病 o Structure 8 SUccessor Clent Handker HandleRequesto c。 ncreteHandler Concretehandlen HandleRequesto Handle Request Institute of Computer Software 2021/215 Nanjing University
Structure 2021/2/5 Institute of Computer Software Nanjing University 8
最病 A Participants 9 口Hand|er 口定义一个处理请求的接口 口(可选)实现后继链 口 Concretehand|er 口处理它所负责的请求 口可访问它的后继者 口如果可处理该请求,就处理之;否则将该请求转发给它的后 继者 a Client 口提交请求 Institute of Computer Software 2021/215 Nanjing University
Participants Handler 定义一个处理请求的接口 (可选)实现后继链 ConcreteHandler 处理它所负责的请求 可访问它的后继者 如果可处理该请求,就处理之;否则将该请求转发给它的后 继者 Client 提交请求 2021/2/5 Institute of Computer Software Nanjing University 9
最病 Collaboration 口当 Client提交一个请求时,请求沿链传递直至有 个 Concretehandler对象负责处理它 a client aConcreteHandler cHandler aConcreteHandler successor successor Sample Code Institute of Computer Software 2021/215 Nanjing University
Collaboration 当Client提交一个请求时,请求沿链传递直至有 一个ConcreteHandler对象负责处理它 2021/2/5 Institute of Computer Software Nanjing University 10 Sample Code