Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server

public Class DetectorConnectionFactory

extends AbstractConnectionFactory
implements Detecting
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.ConnectionFactory.Detecting, org.eclipse.jetty.server.ConnectionFactory
Known Direct Subclasses
org.eclipse.jetty.server.OptionalSslConnectionFactory, org.eclipse.jetty.server.ProxyConnectionFactory
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.Arrays, .LinkedHashSet, .List, java.util.stream.Collectors, org.eclipse.jetty.io.AbstractConnection, .Connection, .EndPoint, .RetainableByteBuffer, org.eclipse.jetty.util.BufferUtil, org.slf4j.Logger, .LoggerFactory

A ConnectionFactory combining multiple Detecting instances that will upgrade to the first one recognizing the bytes in the buffer.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class

Field Summary

Modifier and TypeField and Description
private final List<ConnectionFactory.Detecting>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
DetectorConnectionFactory(ConnectionFactory.Detecting...
the Detecting instances.
detectingConnectionFactories
)

When the first bytes are not recognized by the detectingConnectionFactories, the default behavior is to upgrade to the protocol returned by findNextProtocol(Connector).

Method Summary

Modifier and TypeMethod and Description
public ConnectionFactory.Detecting.Detection

Returns:

A Detection value with the detection outcome of the detectingConnectionFactories.
detect
(ByteBuffer
the buffer to perform a detection against.
buffer
)

Implements org.eclipse.jetty.server.ConnectionFactory.Detecting.detect.

Performs a detection using multiple Detecting instances and returns the aggregated outcome.

public Connection
newConnection(Connector
The Connector creating this connection
connector
,
EndPoint
the EndPoint associated with the connection
endPoint
)

Implements org.eclipse.jetty.server.ConnectionFactory.newConnection.

Creates a new Connection with the given parameters

protected void
nextProtocol(Connector
the connector.
connector
,
EndPoint
the endpoint.
endPoint
,
ByteBuffer
the buffer.
buffer
)

Callback method called when detection was unsuccessful.

private static String
toProtocolString(ConnectionFactory.Detecting... detectingConnectionFactories)

protected static void
upgradeToConnectionFactory(ConnectionFactory
the connection factory to upgrade to.
connectionFactory
,
Connector
the connector.
connector
,
EndPoint
the endpoint.
endPoint
)

Utility method that performs an upgrade to the specified connection factory, disposing of the given resources when needed.

Inherited from org.eclipse.jetty.server.AbstractConnectionFactory:
configurefindNextProtocolfindNextProtocolgetFactoriesgetInputBufferSizegetProtocolgetProtocolssetInputBufferSizetoString

Field Detail

_detectingConnectionFactoriesback to summary
private final List<ConnectionFactory.Detecting> _detectingConnectionFactories
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.component.ContainerLifeCycle.LOG.

Constructor Detail

DetectorConnectionFactoryback to summary
public DetectorConnectionFactory(ConnectionFactory.Detecting... detectingConnectionFactories)

When the first bytes are not recognized by the detectingConnectionFactories, the default behavior is to upgrade to the protocol returned by findNextProtocol(Connector).

Parameters
detectingConnectionFactories:ConnectionFactory.Detecting[]

the Detecting instances.

Method Detail

detectback to summary
public ConnectionFactory.Detecting.Detection detect(ByteBuffer buffer)

Implements org.eclipse.jetty.server.ConnectionFactory.Detecting.detect.

Performs a detection using multiple Detecting instances and returns the aggregated outcome.

Parameters
buffer:ByteBuffer

the buffer to perform a detection against.

Returns:ConnectionFactory.Detecting.Detection

A Detection value with the detection outcome of the detectingConnectionFactories.

Annotations
@Override
newConnectionback to summary
public Connection newConnection(Connector connector, EndPoint endPoint)

Implements org.eclipse.jetty.server.ConnectionFactory.newConnection.

Doc from org.eclipse.jetty.server.ConnectionFactory.newConnection.

Creates a new Connection with the given parameters

Parameters
connector:Connector

The Connector creating this connection

endPoint:EndPoint

the EndPoint associated with the connection

Returns:Connection

a new Connection

Annotations
@Override
nextProtocolback to summary
protected void nextProtocol(Connector connector, EndPoint endPoint, ByteBuffer buffer) throws IllegalStateException

Callback method called when detection was unsuccessful. This implementation upgrades to the protocol returned by findNextProtocol(Connector).

Parameters
connector:Connector

the connector.

endPoint:EndPoint

the endpoint.

buffer:ByteBuffer

the buffer.

toProtocolStringback to summary
private static String toProtocolString(ConnectionFactory.Detecting... detectingConnectionFactories)
upgradeToConnectionFactoryback to summary
protected static void upgradeToConnectionFactory(ConnectionFactory connectionFactory, Connector connector, EndPoint endPoint) throws IllegalStateException

Utility method that performs an upgrade to the specified connection factory, disposing of the given resources when needed.

Parameters
connectionFactory:ConnectionFactory

the connection factory to upgrade to.

connector:Connector

the connector.

endPoint:EndPoint

the endpoint.

org.eclipse.jetty.server back to summary

private Class DetectorConnectionFactory.DetectionFailureException

extends RuntimeException
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

DetectionFailureExceptionback to summary
public DetectionFailureException(Throwable cause)
org.eclipse.jetty.server back to summary

private Class DetectorConnectionFactory.DetectorConnection

extends AbstractConnection
implements UpgradeFrom, UpgradeTo
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.io.Connection.UpgradeTo, org.eclipse.jetty.io.Connection.UpgradeFrom

Field Summary

Modifier and TypeField and Description
private final RetainableByteBuffer
private final Connector

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private boolean
detectAndUpgrade()

Returns: true when upgrade was performed, false otherwise.

public void
onFillable()

Implements abstract org.eclipse.jetty.io.AbstractConnection.onFillable.

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

public void
onOpen()

Overrides org.eclipse.jetty.io.AbstractConnection.onOpen.

Implements org.eclipse.jetty.io.Connection.onOpen.

Callback method invoked when this connection is opened.

public ByteBuffer
onUpgradeFrom()

Implements org.eclipse.jetty.io.Connection.UpgradeFrom.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.

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.
byteBuffer
)

Implements org.eclipse.jetty.io.Connection.UpgradeTo.onUpgradeTo.

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.

private void
Inherited from org.eclipse.jetty.io.AbstractConnection:
addEventListenerclosefailedCallbackfillInterestedgetBytesIngetBytesOutgetCreatedTimeStampgetEndPointgetExecutorgetInputBufferSizegetInvocationTypegetMessagesIngetMessagesOutisFillInterestedonCloseonFillInterestedFailedonIdleExpiredonReadTimeoutremoveEventListenersetInputBufferSizetoConnectionStringtoStringtryFillInterested

Field Detail

_bufferback to summary
private final RetainableByteBuffer _buffer
_connectorback to summary
private final Connector _connector

Constructor Detail

DetectorConnectionback to summary
private DetectorConnection(EndPoint endp, Connector connector)

Method Detail

detectAndUpgradeback to summary
private boolean detectAndUpgrade()
Returns:boolean

true when upgrade was performed, false otherwise.

onFillableback to summary
public void onFillable()

Implements abstract org.eclipse.jetty.io.AbstractConnection.onFillable.

Doc from org.eclipse.jetty.io.AbstractConnection.onFillable.

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

Annotations
@Override
onOpenback to summary
public void onOpen()

Overrides org.eclipse.jetty.io.AbstractConnection.onOpen.

Implements org.eclipse.jetty.io.Connection.onOpen.

Doc from org.eclipse.jetty.io.Connection.onOpen.

Callback method invoked when this connection is opened.

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

Annotations
@Override
onUpgradeFromback to summary
public ByteBuffer onUpgradeFrom()

Implements org.eclipse.jetty.io.Connection.UpgradeFrom.onUpgradeFrom.

Doc from org.eclipse.jetty.io.Connection.UpgradeFrom.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.

Annotations
@Override
onUpgradeToback to summary
public void onUpgradeTo(ByteBuffer byteBuffer)

Implements org.eclipse.jetty.io.Connection.UpgradeTo.onUpgradeTo.

Doc from org.eclipse.jetty.io.Connection.UpgradeTo.onUpgradeTo.

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
byteBuffer: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.

Annotations
@Override
releaseAndCloseback to summary
private void releaseAndClose(Throwable failure)