Handling events using the chain of responsibility pattern
The chain of responsibility pattern helps avoid tying the handler logic to the sender that fired the event. This pattern was identified by the GoF’s book.
Motivation
The program receives an initial triggered event. Each chained handler decides whether to process the request or pass it on to the next handler without responding. A pattern can consist of command objects that are processed by a series of handler objects. Some handlers can act as dispatchers, capable of sending commands in different directions to form a responsibility tree.
The chain of responsibility pattern allows you to build a chain of implementations in which a certain action is performed before or after calling the next handler in the chain.
Finding it in the JDK
The java.logging
module includes the java.util.logging
package, which contains a Logger
class, intended for recording application component messages. Loggers can be chained and...