Class AbstractNetworkConnector

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.AbstractConnector
org.eclipse.jetty.server.AbstractNetworkConnector
All Implemented Interfaces:
Closeable, AutoCloseable, Connector, NetworkConnector, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Graceful, org.eclipse.jetty.util.component.LifeCycle
Direct Known Subclasses:
ServerConnector

@ManagedObject("AbstractNetworkConnector") public abstract class AbstractNetworkConnector extends AbstractConnector implements NetworkConnector
An abstract Network Connector.

Extends the AbstractConnector support for the NetworkConnector interface.

  • Constructor Details

    • AbstractNetworkConnector

      public AbstractNetworkConnector(Server server, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.ByteBufferPool bufferPool, int acceptors, ConnectionFactory... factories)
  • Method Details

    • setHost

      public void setHost(String host)
    • getHost

      @ManagedAttribute("The network interface this connector binds to as an IP address or a hostname. If null or 0.0.0.0, then bind to all interfaces.") public String getHost()
      Specified by:
      getHost in interface NetworkConnector
      Returns:
      The hostname representing the interface to which this connector will bind, or null for all interfaces.
    • setPort

      public void setPort(int port)
    • getPort

      @ManagedAttribute("Port this connector listens on. If set the 0 a random port is assigned which may be obtained with getLocalPort()") public int getPort()
      Specified by:
      getPort in interface NetworkConnector
      Returns:
      The configured port for the connector or 0 if any available port may be used.
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface NetworkConnector
      Returns:
      The actual port the connector is listening on, or -1 if it has not been opened, or -2 if it has been closed.
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class AbstractConnector
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class AbstractConnector
      Throws:
      Exception
    • open

      public void open() throws IOException
      Description copied from interface: NetworkConnector

      Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).

      Specified by:
      open in interface NetworkConnector
      Throws:
      IOException - if this connector cannot be opened
      See Also:
    • close

      public void close()
      Description copied from interface: NetworkConnector

      Performs the activities needed to close the network communication (for example, to stop accepting network connections).

      Once a connector has been closed, it cannot be opened again without first calling LifeCycle.stop() and it will not be active again until a subsequent call to LifeCycle.start()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface NetworkConnector
    • shutdown

      public CompletableFuture<Void> shutdown()
      Specified by:
      shutdown in interface org.eclipse.jetty.util.component.Graceful
      Overrides:
      shutdown in class AbstractConnector
    • handleAcceptFailure

      protected boolean handleAcceptFailure(Throwable ex)
      Overrides:
      handleAcceptFailure in class AbstractConnector
    • toString

      public String toString()
      Overrides:
      toString in class AbstractConnector