- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 148字
- 2021-06-25 20:52:36
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.
推薦閱讀
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- Python王者歸來
- Podman實戰
- Python程序設計案例教程
- Learning Apache Mahout Classification
- Hands-On Reinforcement Learning with Python
- R Deep Learning Cookbook
- 青少年學Python(第1冊)
- Raspberry Pi Home Automation with Arduino(Second Edition)
- 區塊鏈技術與應用
- Mastering React
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- 用案例學Java Web整合開發
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Python 3 Object:oriented Programming(Second Edition)