001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.net.server; 015 016import java.io.Closeable; 017import java.io.IOException; 018 019/** 020 * A client of a {@link ServerRunner}. 021 * <p> 022 * This interface exists primarily to abstract away the details of the client's 023 * underlying {@code Socket} and the concurrency associated with handling 024 * multiple clients. Such realities make it difficult to create effective unit 025 * tests for the {@link ServerRunner} that are easy to understand and maintain. 026 * <p> 027 * This interface captures the only those details about a client that the 028 * {@code ServerRunner} cares about; namely, that it is something that 029 * <ol> 030 * <li>is Runnable — i.e. it can be executed concurrently</li> 031 * <li>holds resources that need to be closed before the client is 032 * discarded</li> 033 * </ol> 034 * 035 * @author Carl Harris 036 */ 037public interface Client extends Runnable, Closeable { 038 039 /** 040 * Closes any resources that are held by the client. 041 * <p> 042 * Note that (as described in Doug Lea's discussion about interrupting I/O 043 * operations in "Concurrent Programming in Java" - Addison-Wesley Professional, 044 * 2nd edition, 1999) this method is used to interrupt any blocked I/O operation 045 * in the client when the server is shutting down. The client implementation 046 * must anticipate this potential, and gracefully exit when the blocked I/O 047 * operation throws the relevant {@link IOException} subclass. 048 * <p> 049 * Note also, that unlike {@link Closeable#close()} this method is not permitted 050 * to propagate any {@link IOException} that occurs when closing the underlying 051 * resource(s). 052 */ 053 void close(); 054 055}