View Javadoc
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.IOException;
17  
18  import ch.qos.logback.core.spi.ContextAware;
19  
20  /**
21   * An object that is responsible for the asynchronous execution of a
22   * socket server.
23   * <p>
24   * This interface exists primarily to allow the runner to be mocked for
25   * the purpose of unit testing the socket server implementation.
26   * 
27   * @author Carl Harris
28   */
29  public interface ServerRunner<T extends Client> extends ContextAware, Runnable {
30  
31      /**
32       * Gets a flag indicating whether the server is currently running.
33       * @return flag state
34       */
35      boolean isRunning();
36  
37      /**
38       * Stops execution of the runner.
39       * <p>
40       * This method must cause all I/O and thread resources associated with
41       * the runner to be released.  If the receiver has not been started, this
42       * method must have no effect.
43       * @throws IOException
44       */
45      void stop() throws IOException;
46  
47      /**
48       * Presents each connected client to the given visitor.   
49       * @param visitor the subject visitor
50       */
51      void accept(ClientVisitor<T> visitor);
52  
53  }