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

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.
主站蜘蛛池模板: 依安县| 万盛区| 榆中县| 永寿县| 凌云县| 闸北区| 琼中| 开江县| 甘南县| 阳西县| 新巴尔虎右旗| 鄂托克前旗| 罗城| 丰都县| 克东县| 宜章县| 左权县| 汝城县| 湖口县| 瓮安县| 兴城市| 姜堰市| 贵港市| 平远县| 乃东县| 定襄县| 奉贤区| 乌拉特前旗| 漳州市| 乐山市| 江达县| 双流县| 潮州市| 安多县| 天峨县| 林州市| 阳山县| 福州市| 山西省| 应用必备| 北辰区|