1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.server; 20 21 import java.io.IOException; 22 23 /** 24 * <p>A {@link Connector} for TCP/IP network connectors</p> 25 */ 26 public interface NetworkConnector extends Connector, AutoCloseable 27 { 28 /** 29 * <p>Performs the activities needed to open the network communication 30 * (for example, to start accepting incoming network connections).</p> 31 * 32 * @throws IOException if this connector cannot be opened 33 * @see #close() 34 */ 35 void open() throws IOException; 36 37 /** 38 * <p>Performs the activities needed to close the network communication 39 * (for example, to stop accepting network connections).</p> 40 * Once a connector has been closed, it cannot be opened again without first 41 * calling {@link #stop()} and it will not be active again until a subsequent call to {@link #start()} 42 * @throws IOException if this connector cannot be closed 43 */ 44 @Override 45 void close(); 46 47 /* ------------------------------------------------------------ */ 48 /** 49 * A Connector may be opened and not started (to reserve a port) 50 * or closed and running (to allow graceful shutdown of existing connections) 51 * @return True if the connector is Open. 52 */ 53 boolean isOpen(); 54 55 /** 56 * @return The hostname representing the interface to which 57 * this connector will bind, or null for all interfaces. 58 */ 59 String getHost(); 60 61 /** 62 * @return The configured port for the connector or 0 if any available 63 * port may be used. 64 */ 65 int getPort(); 66 67 /** 68 * @return The actual port the connector is listening on, or 69 * -1 if it has not been opened, or -2 if it has been closed. 70 */ 71 int getLocalPort(); 72 }