2019-10-22 07:15:35 +02:00
|
|
|
/*
|
2016-01-27 22:20:42 +00:00
|
|
|
* The MIT License
|
2021-02-14 15:27:57 +05:30
|
|
|
* Copyright © 2014-2021 Ilkka Seppälä
|
2016-01-27 22:20:42 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2019-10-22 07:15:35 +02:00
|
|
|
|
2015-08-18 21:55:25 +03:00
|
|
|
package com.iluwatar.chain;
|
|
|
|
|
2021-03-13 13:19:21 +01:00
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2016-10-23 19:59:03 +02:00
|
|
|
|
2015-08-18 21:55:25 +03:00
|
|
|
/**
|
2019-11-10 00:57:14 +05:30
|
|
|
* RequestHandler.
|
2015-08-18 21:55:25 +03:00
|
|
|
*/
|
2021-03-13 13:19:21 +01:00
|
|
|
@Slf4j
|
|
|
|
@AllArgsConstructor
|
2015-08-18 21:55:25 +03:00
|
|
|
public abstract class RequestHandler {
|
|
|
|
|
2020-07-30 20:28:47 +03:00
|
|
|
private final RequestHandler next;
|
2015-08-18 21:55:25 +03:00
|
|
|
|
2015-12-25 23:49:28 +02:00
|
|
|
/**
|
2019-11-10 00:57:14 +05:30
|
|
|
* Request handler.
|
2015-12-25 23:49:28 +02:00
|
|
|
*/
|
2015-11-01 18:48:43 -05:00
|
|
|
public void handleRequest(Request req) {
|
|
|
|
if (next != null) {
|
|
|
|
next.handleRequest(req);
|
|
|
|
}
|
|
|
|
}
|
2015-08-18 21:55:25 +03:00
|
|
|
|
2015-11-01 18:48:43 -05:00
|
|
|
protected void printHandling(Request req) {
|
2016-10-23 19:59:03 +02:00
|
|
|
LOGGER.info("{} handling request \"{}\"", this, req);
|
2015-11-01 18:48:43 -05:00
|
|
|
}
|
2015-08-18 21:55:25 +03:00
|
|
|
|
2015-11-01 18:48:43 -05:00
|
|
|
@Override
|
|
|
|
public abstract String toString();
|
2015-08-18 21:55:25 +03:00
|
|
|
}
|