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.IOException;
017
018import ch.qos.logback.core.spi.ContextAware;
019
020/**
021 * An object that is responsible for the asynchronous execution of a socket
022 * server.
023 * <p>
024 * This interface exists primarily to allow the runner to be mocked for the
025 * purpose of unit testing the socket server implementation.
026 * 
027 * @author Carl Harris
028 */
029public interface ServerRunner<T extends Client> extends ContextAware, Runnable {
030
031    /**
032     * Gets a flag indicating whether the server is currently running.
033     * 
034     * @return flag state
035     */
036    boolean isRunning();
037
038    /**
039     * Stops execution of the runner.
040     * <p>
041     * This method must cause all I/O and thread resources associated with the
042     * runner to be released. If the receiver has not been started, this method must
043     * have no effect.
044     * 
045     * @throws IOException
046     */
047    void stop() throws IOException;
048
049    /**
050     * Presents each connected client to the given visitor.
051     * 
052     * @param visitor the subject visitor
053     */
054    void accept(ClientVisitor<T> visitor);
055
056}