官术网_书友最值得收藏!

Applicability and examples

What follows is the applicability and examples of the chain-of-responsibility pattern:

  • Event handlers: For example, most GUI frameworks use the chain-of-responsibility pattern to handle events. Let's say, for example, a window contains a panel that contains some buttons. We have to write the event handler of the button. If we decide to skip it and pass it on, the next one in the chain will be able to handle the request: the panel. If the panel skips it, it will go to the window.
  • Log handlers: Similar to the event handlers, each log handler will log a specific request based on its status, or it will pass it on to the next handler.
  • Servlets: In Java, javax.servlet.Filter (http://docs.oracle.com/javaee/7/api/javax/servlet/Filter.html) is used to filter requests or responses. The doFilter method also receives the filter chain as a parameter, and it can pass the request on.
主站蜘蛛池模板: 多伦县| 邵阳市| 泸溪县| 峨边| 宜良县| 泰顺县| 大兴区| 施秉县| 西宁市| 旺苍县| 无为县| 斗六市| 宜都市| 武威市| 桑植县| 临夏市| 彩票| 桃江县| 通江县| 黄浦区| 宁安市| 株洲市| 托里县| 延川县| 高尔夫| 河间市| 博野县| 榆树市| 明水县| 方正县| 石家庄市| 宁晋县| 民乐县| 旺苍县| 金寨县| 武乡县| 永寿县| 威远县| 祥云县| 道真| 从化市|