public class DetectorConnectionFactory extends AbstractConnectionFactory implements ConnectionFactory.Detecting
ConnectionFactory
combining multiple Detecting
instances that will upgrade to
the first one recognizing the bytes in the buffer.Modifier and Type | Class and Description |
---|---|
private static class |
DetectorConnectionFactory.DetectionFailureException |
private class |
DetectorConnectionFactory.DetectorConnection |
AbstractLifeCycle.AbstractLifeCycleListener
ConnectionFactory.Detecting.Detection
ConnectionFactory.Detecting, ConnectionFactory.Upgrading
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
private java.util.List<ConnectionFactory.Detecting> |
_detectingConnectionFactories |
private static Logger |
LOG |
Constructor and Description |
---|
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 AbstractConnectionFactory.findNextProtocol(Connector) . |
Modifier and Type | Method and Description |
---|---|
ConnectionFactory.Detecting.Detection |
detect(java.nio.ByteBuffer buffer)
Performs a detection using multiple
ConnectionFactory.Detecting instances and returns the aggregated outcome. |
Connection |
newConnection(Connector connector,
EndPoint endPoint)
Creates a new
Connection with the given parameters |
protected void |
nextProtocol(Connector connector,
EndPoint endPoint,
java.nio.ByteBuffer buffer)
Callback method called when detection was unsuccessful.
|
private static java.lang.String |
toProtocolString(ConnectionFactory.Detecting... detectingConnectionFactories) |
protected static void |
upgradeToConnectionFactory(ConnectionFactory connectionFactory,
Connector connector,
EndPoint endPoint)
Utility method that performs an upgrade to the specified connection factory, disposing of the given resources when needed.
|
configure, findNextProtocol, findNextProtocol, getFactories, getInputBufferSize, getProtocol, getProtocols, setInputBufferSize, toString
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getProtocol, getProtocols
dumpContainer, dumpIterable, dumpMapEntries, dumpObjects, dumpSelf, named
private static final Logger LOG
private final java.util.List<ConnectionFactory.Detecting> _detectingConnectionFactories
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 AbstractConnectionFactory.findNextProtocol(Connector)
.
detectingConnectionFactories
- the Detecting
instances.private static java.lang.String toProtocolString(ConnectionFactory.Detecting... detectingConnectionFactories)
public ConnectionFactory.Detecting.Detection detect(java.nio.ByteBuffer buffer)
ConnectionFactory.Detecting
instances and returns the aggregated outcome.detect
in interface ConnectionFactory.Detecting
buffer
- the buffer to perform a detection against.Detecting.Detection
value with the detection outcome of the detectingConnectionFactories
.protected static void upgradeToConnectionFactory(ConnectionFactory connectionFactory, Connector connector, EndPoint endPoint) throws java.lang.IllegalStateException
connectionFactory
- the connection factory to upgrade to.connector
- the connector.endPoint
- the endpoint.java.lang.IllegalStateException
protected void nextProtocol(Connector connector, EndPoint endPoint, java.nio.ByteBuffer buffer) throws java.lang.IllegalStateException
Callback method called when detection was unsuccessful.
This implementation upgrades to the protocol returned by AbstractConnectionFactory.findNextProtocol(Connector)
.
connector
- the connector.endPoint
- the endpoint.buffer
- the buffer.java.lang.IllegalStateException
public Connection newConnection(Connector connector, EndPoint endPoint)
ConnectionFactory
Creates a new Connection
with the given parameters
newConnection
in interface ConnectionFactory
connector
- The Connector
creating this connectionendPoint
- the EndPoint
associated with the connectionConnection