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

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.
主站蜘蛛池模板: 临湘市| 张家港市| 蓝山县| 泉州市| 修武县| 志丹县| 泰安市| 同江市| 张北县| 石屏县| 广东省| 长春市| 蓬安县| 旌德县| 徐水县| 深州市| 沙洋县| 根河市| 新竹市| 三亚市| 斗六市| 三穗县| 青田县| 崇文区| 井研县| 库尔勒市| 林州市| 台湾省| 紫金县| 南丹县| 平罗县| 土默特左旗| 大关县| 微博| 中阳县| 凭祥市| 菏泽市| 湘潭县| 会泽县| 汝城县| 漯河市|