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

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.
主站蜘蛛池模板: 丹东市| 本溪| 台州市| 江永县| 营口市| 霸州市| 墨脱县| 读书| 淮南市| 高尔夫| 六枝特区| 正安县| 房山区| 株洲县| 吉林市| 台中县| 广东省| 安徽省| 文昌市| 元阳县| 论坛| 邵阳县| 绍兴市| 景洪市| 正蓝旗| 芦溪县| 武清区| 治县。| 安龙县| 驻马店市| 淮安市| 金山区| 玉溪市| 临城县| 日土县| 青岛市| 亚东县| 德兴市| 车致| 五寨县| 禄劝|