Properties:
- Lets a request to be passed sequentially to a set of handlers.
- Each handler decides wheter to handle the request or pass it to next handler.
Implementation:
- Handler interface declares operations to handle requests.
- ConcreteHandler decides wheter to handle the request or pass it to next handler.
Java Standard Library Implementations:
Example Usage:
public class Logger {
public void log(LogRecord paramLogRecord){
Logger localLogger = this;
while (localLogger != null) {
// send log record to all handlers
for (Handler localHandler : localLogger.getHandlers()) {
localHandler.publish(paramLogRecord);
}
if (!localLogger.getUseParentHandlers())
{
break;
}
localLogger = localLogger.getParent();
}
}
....
}
Comments
Post a Comment