- 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.
推薦閱讀
- 深入理解Bootstrap
- C和C++安全編碼(原書第2版)
- Spring Boot企業級項目開發實戰
- 跟戴銘學iOS編程:理順核心知識點
- Scratch從入門到精通
- Robot Framework Test Automation
- Maven for Eclipse
- 計算語言學導論
- MySQL數據庫應用實戰教程(慕課版)
- Mastering Machine Learning with R
- Developing Java Applications with Spring and Spring Boot
- Java核心編程
- Python人工智能項目實戰
- Mastering PostgreSQL 11(Second Edition)
- Python for Secret Agents