Top Description Inners Methods
org.eclipse.jetty.io

public Interface Connection

extends Closeable
Known Direct Implementers
org.eclipse.jetty.io.AbstractConnection
Imports
java.io.Closeable, java.nio.ByteBuffer, java.util.EventListener, java.util.concurrent.TimeoutException, org.eclipse.jetty.util.component.Container

A Connection is associated to an EndPoint so that I/O events happening on the EndPoint can be processed by the Connection.

A typical implementation of Connection overrides onOpen() to set read interest on the EndPoint, and when the EndPoint signals read readyness, this Connection can read bytes from the network and interpret them.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Connection.Listener

A Listener for connection events.

public static interface
Connection.UpgradeFrom

Connection implementations implement this interface when they can upgrade from the protocol they speak (for example HTTP/1.1) to a different protocol (e.g. HTTP/2).

public static interface
Connection.UpgradeTo

Connection implementations implement this interface when they can be upgraded to the protocol they speak (e.g. HTTP/2) from a different protocol (e.g. HTTP/1.1).

Method Summary

Modifier and TypeMethod and Description
public void
addEventListener(EventListener
the listener to add
listener
)

Adds a listener of connection events.

public void
close()

Redeclares java.io.Closeable.close.

Performs a logical close of this connection.

public long
public long
public long
public EndPoint
getEndPoint()

Returns: the EndPoint associated with this Connection.

public long
public long
public void
onClose(Throwable
The cause of the close or null for a normal close
cause
)

Callback method invoked when this connection is closed.

public boolean

Returns:

true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
onIdleExpired
(TimeoutException timeoutException)

Callback method invoked upon an idle timeout event.

public void
onOpen()

Callback method invoked when this connection is opened.

public void
removeEventListener(EventListener
the listener to remove
listener
)

Removes a listener of connection events.

Method Detail

addEventListenerback to summary
public void addEventListener(EventListener listener)

Adds a listener of connection events.

Parameters
listener:EventListener

the listener to add

closeback to summary
public void close()

Redeclares java.io.Closeable.close.

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.

Annotations
@Override
getBytesInback to summary
public long getBytesIn()
getBytesOutback to summary
public long getBytesOut()
getCreatedTimeStampback to summary
public long getCreatedTimeStamp()
getEndPointback to summary
public EndPoint getEndPoint()
Returns:EndPoint

the EndPoint associated with this Connection.

getMessagesInback to summary
public long getMessagesIn()
getMessagesOutback to summary
public long getMessagesOut()
onCloseback to summary
public void onClose(Throwable cause)

Callback method invoked when this connection is closed.

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

Parameters
cause:Throwable

The cause of the close or null for a normal close

onIdleExpiredback to summary
public boolean onIdleExpired(TimeoutException timeoutException)

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.

Returns:boolean

true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.

onOpenback to summary
public void onOpen()

Callback method invoked when this connection is opened.

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

removeEventListenerback to summary
public void removeEventListener(EventListener listener)

Removes a listener of connection events.

Parameters
listener:EventListener

the listener to remove

org.eclipse.jetty.io back to summary

public Interface Connection.Listener

extends EventListener
Known Direct Implementers
org.eclipse.jetty.io.ConnectionStatistics

A Listener for connection events.

Listeners can be added to a Connection to get open and close events. The AbstractConnectionFactory implements a pattern where objects implement this interface that have been added via Container#addBean(Object) to the Connector or ConnectionFactory are added as listeners to all new connections

Method Summary

Modifier and TypeMethod and Description
public default void
onClosed(Connection connection)

public default void
onOpened(Connection connection)

Method Detail

onClosedback to summary
public default void onClosed(Connection connection)
onOpenedback to summary
public default void onOpened(Connection connection)
org.eclipse.jetty.io back to summary

public Interface Connection.UpgradeFrom


Connection implementations implement this interface when they can upgrade from the protocol they speak (for example HTTP/1.1) to a different protocol (e.g. HTTP/2).

See Also
EndPoint#upgrade(Connection), UpgradeTo

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer

Returns:

a buffer of unconsumed bytes to pass to the upgrade-to connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes. The returned buffer may be null if there are no unconsumed bytes.
onUpgradeFrom
()

Invoked during an upgrade to produce a buffer containing bytes that have not been consumed by this connection, and that must be consumed by the upgrade-to connection.

Method Detail

onUpgradeFromback to summary
public ByteBuffer onUpgradeFrom()

Invoked during an upgrade to produce a buffer containing bytes that have not been consumed by this connection, and that must be consumed by the upgrade-to connection.

Returns:ByteBuffer

a buffer of unconsumed bytes to pass to the upgrade-to connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes. The returned buffer may be null if there are no unconsumed bytes.

org.eclipse.jetty.io back to summary

public Interface Connection.UpgradeTo

Known Direct Implementers
org.eclipse.jetty.io.ssl.SslConnection

Connection implementations implement this interface when they can be upgraded to the protocol they speak (e.g. HTTP/2) from a different protocol (e.g. HTTP/1.1).

Method Summary

Modifier and TypeMethod and Description
public void
onUpgradeTo(ByteBuffer
a non-null buffer of unconsumed bytes received from the upgrade-from connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes.
buffer
)

Invoked during an upgrade to receive a buffer containing bytes that have not been consumed by the upgrade-from connection, and that must be consumed by this connection.

Method Detail

onUpgradeToback to summary
public void onUpgradeTo(ByteBuffer buffer)

Invoked during an upgrade to receive a buffer containing bytes that have not been consumed by the upgrade-from connection, and that must be consumed by this connection.

Parameters
buffer:ByteBuffer

a non-null buffer of unconsumed bytes received from the upgrade-from connection. The buffer does not belong to any pool and should be discarded after having consumed its bytes.