- 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.
推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- 軟件項目估算
- TypeScript入門與實戰
- FreeSWITCH 1.6 Cookbook
- Python Network Programming Cookbook(Second Edition)
- Effective Python Penetration Testing
- 深度學習:算法入門與Keras編程實踐
- The HTML and CSS Workshop
- 移動界面(Web/App)Photoshop UI設計十全大補
- Access 2010數據庫應用技術(第2版)
- Python爬蟲、數據分析與可視化:工具詳解與案例實戰
- 計算機應用基礎教程(Windows 7+Office 2010)
- QlikView Unlocked
- R語言數據挖掘:實用項目解析
- Hands-On Dependency Injection in Go