Class AbstractConnection

java.lang.Object
org.eclipse.jetty.io.AbstractConnection
All Implemented Interfaces:
Closeable, AutoCloseable, Connection, Invocable
Direct Known Subclasses:
AbstractMetaDataConnection, ConnectHandler.DownstreamConnection, ConnectHandler.UpstreamConnection, HTTP2Connection, HTTP3StreamConnection, HttpConnectionOverFCGI, HttpConnectionOverHTTP, InstructionStreamConnection, NegotiatingClientConnection, NegotiatingServerConnection, ProxyProtocolClientConnectionFactory.ProxyProtocolConnection, QuicConnection, SslConnection, UnidirectionalStreamConnection, WebSocketConnection

public abstract class AbstractConnection extends Object implements Connection, Invocable

A convenience base implementation of Connection.

This class uses the capabilities of the EndPoint API to provide a more traditional style of async reading. A call to fillInterested() will schedule a callback to onFillable() or onFillInterestedFailed(Throwable) as appropriate.

  • Constructor Details

    • AbstractConnection

      protected AbstractConnection(EndPoint endPoint, Executor executor)
  • Method Details

    • getInvocationType

      @Deprecated public Invocable.InvocationType getInvocationType()
      Deprecated.
      Specified by:
      getInvocationType in interface Invocable
      Returns:
      The InvocationType of this object
    • addEventListener

      public void addEventListener(EventListener listener)
      Description copied from interface: Connection

      Adds a listener of connection events.

      Specified by:
      addEventListener in interface Connection
      Parameters:
      listener - the listener to add
    • removeEventListener

      public void removeEventListener(EventListener eventListener)
      Description copied from interface: Connection

      Removes a listener of connection events.

      Specified by:
      removeEventListener in interface Connection
      Parameters:
      eventListener - the listener to remove
    • getInputBufferSize

      public int getInputBufferSize()
    • setInputBufferSize

      public void setInputBufferSize(int inputBufferSize)
    • getExecutor

      protected Executor getExecutor()
    • failedCallback

      protected void failedCallback(Callback callback, Throwable x)
    • fillInterested

      public void fillInterested()

      Utility method to be called to register read interest.

      After a call to this method, onFillable() or onFillInterestedFailed(Throwable) will be called back as appropriate.

      See Also:
    • tryFillInterested

      public void tryFillInterested(Callback callback)
    • isFillInterested

      public boolean isFillInterested()
    • onFillable

      public abstract void onFillable()

      Callback method invoked when the endpoint is ready to be read.

      See Also:
    • onFillInterestedFailed

      protected void onFillInterestedFailed(Throwable cause)

      Callback method invoked when the endpoint failed to be ready to be read.

      Parameters:
      cause - the exception that caused the failure
    • onReadTimeout

      protected boolean onReadTimeout(TimeoutException timeout)

      Callback method invoked when the endpoint failed to be ready to be read after a timeout

      Parameters:
      timeout - the cause of the read timeout
      Returns:
      true to signal that the endpoint must be closed, false to keep the endpoint open
    • onOpen

      public void onOpen()
      Description copied from interface: Connection

      Callback method invoked when this connection is opened.

      Creators of the connection implementation are responsible for calling this method.

      Specified by:
      onOpen in interface Connection
    • onClose

      public void onClose(Throwable cause)
      Description copied from interface: Connection

      Callback method invoked when this connection is closed.

      Creators of the connection implementation are responsible for calling this method.

      Specified by:
      onClose in interface Connection
      Parameters:
      cause - The cause of the close or null for a normal close
    • getEndPoint

      public EndPoint getEndPoint()
      Specified by:
      getEndPoint in interface Connection
      Returns:
      the EndPoint associated with this Connection.
    • close

      public void close()
      Description copied from interface: Connection

      Performs a logical close of this connection.

      For simple connections, this may just mean to delegate the close to the associated EndPoint but, for example, SSL connections should write the SSL close message before closing the associated EndPoint.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Connection
    • onIdleExpired

      public boolean onIdleExpired(TimeoutException timeoutException)
      Description copied from interface: Connection

      Callback method invoked upon an idle timeout event.

      Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.

      When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.

      Specified by:
      onIdleExpired in interface Connection
      Returns:
      true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
    • getMessagesIn

      public long getMessagesIn()
      Specified by:
      getMessagesIn in interface Connection
    • getMessagesOut

      public long getMessagesOut()
      Specified by:
      getMessagesOut in interface Connection
    • getBytesIn

      public long getBytesIn()
      Specified by:
      getBytesIn in interface Connection
    • getBytesOut

      public long getBytesOut()
      Specified by:
      getBytesOut in interface Connection
    • getCreatedTimeStamp

      public long getCreatedTimeStamp()
      Specified by:
      getCreatedTimeStamp in interface Connection
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • toConnectionString

      public String toConnectionString()