1 /**
2 * Logback: the reliable, generic, fast and flexible logging framework.
3 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4 *
5 * This program and the accompanying materials are dual-licensed under
6 * either the terms of the Eclipse Public License v1.0 as published by
7 * the Eclipse Foundation
8 *
9 * or (per the licensee's choosing)
10 *
11 * under the terms of the GNU Lesser General Public License version 2.1
12 * as published by the Free Software Foundation.
13 */
14 package ch.qos.logback.core.net.server;
15
16 import java.io.Closeable;
17 import java.io.IOException;
18
19 /**
20 * A client of a {@link ServerRunner}.
21 * <p>
22 * This interface exists primarily to abstract away the details of the client's
23 * underlying {@code Socket} and the concurrency associated with handling
24 * multiple clients. Such realities make it difficult to create effective unit
25 * tests for the {@link ServerRunner} that are easy to understand and maintain.
26 * <p>
27 * This interface captures the only those details about a client that the
28 * {@code ServerRunner} cares about; namely, that it is something that
29 * <ol>
30 * <li>is Runnable — i.e. it can be executed concurrently</li>
31 * <li>holds resources that need to be closed before the client is
32 * discarded</li>
33 * </ol>
34 *
35 * @author Carl Harris
36 */
37 public interface Client extends Runnable, Closeable {
38
39 /**
40 * Closes any resources that are held by the client.
41 * <p>
42 * Note that (as described in Doug Lea's discussion about interrupting I/O
43 * operations in "Concurrent Programming in Java" - Addison-Wesley Professional,
44 * 2nd edition, 1999) this method is used to interrupt any blocked I/O operation
45 * in the client when the server is shutting down. The client implementation
46 * must anticipate this potential, and gracefully exit when the blocked I/O
47 * operation throws the relevant {@link IOException} subclass.
48 * <p>
49 * Note also, that unlike {@link Closeable#close()} this method is not permitted
50 * to propagate any {@link IOException} that occurs when closing the underlying
51 * resource(s).
52 */
53 void close();
54
55 }