Package org.eclipse.jetty.server
Class DetectorConnectionFactory
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.AbstractConnectionFactory
-
- org.eclipse.jetty.server.DetectorConnectionFactory
-
- All Implemented Interfaces:
ConnectionFactory
,ConnectionFactory.Detecting
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
- Direct Known Subclasses:
OptionalSslConnectionFactory
,ProxyConnectionFactory
public class DetectorConnectionFactory extends AbstractConnectionFactory implements ConnectionFactory.Detecting
AConnectionFactory
combining multipleConnectionFactory.Detecting
instances that will upgrade to the first one recognizing the bytes in the buffer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DetectorConnectionFactory.DetectionFailureException
private class
DetectorConnectionFactory.DetectorConnection
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.ConnectionFactory
ConnectionFactory.Detecting, ConnectionFactory.Upgrading
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.ConnectionFactory.Detecting
ConnectionFactory.Detecting.Detection
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ConnectionFactory.Detecting>
_detectingConnectionFactories
private static Logger
LOG
-
Constructor Summary
Constructors Constructor Description DetectorConnectionFactory(ConnectionFactory.Detecting... detectingConnectionFactories)
When the first bytes are not recognized by thedetectingConnectionFactories
, the default behavior is to upgrade to the protocol returned byAbstractConnectionFactory.findNextProtocol(Connector)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectionFactory.Detecting.Detection
detect(java.nio.ByteBuffer buffer)
Performs a detection using multipleConnectionFactory.Detecting
instances and returns the aggregated outcome.Connection
newConnection(Connector connector, EndPoint endPoint)
Creates a newConnection
with the given parametersprotected 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.-
Methods inherited from class org.eclipse.jetty.server.AbstractConnectionFactory
configure, findNextProtocol, findNextProtocol, getFactories, getInputBufferSize, getProtocol, getProtocols, setInputBufferSize, toString
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
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
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.server.ConnectionFactory
getProtocol, getProtocols
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_detectingConnectionFactories
private final java.util.List<ConnectionFactory.Detecting> _detectingConnectionFactories
-
-
Constructor Detail
-
DetectorConnectionFactory
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 byAbstractConnectionFactory.findNextProtocol(Connector)
.- Parameters:
detectingConnectionFactories
- theConnectionFactory.Detecting
instances.
-
-
Method Detail
-
toProtocolString
private static java.lang.String toProtocolString(ConnectionFactory.Detecting... detectingConnectionFactories)
-
detect
public ConnectionFactory.Detecting.Detection detect(java.nio.ByteBuffer buffer)
Performs a detection using multipleConnectionFactory.Detecting
instances and returns the aggregated outcome.- Specified by:
detect
in interfaceConnectionFactory.Detecting
- Parameters:
buffer
- the buffer to perform a detection against.- Returns:
- A
ConnectionFactory.Detecting.Detection
value with the detection outcome of thedetectingConnectionFactories
.
-
upgradeToConnectionFactory
protected static void upgradeToConnectionFactory(ConnectionFactory connectionFactory, Connector connector, EndPoint endPoint) throws java.lang.IllegalStateException
Utility method that performs an upgrade to the specified connection factory, disposing of the given resources when needed.- Parameters:
connectionFactory
- the connection factory to upgrade to.connector
- the connector.endPoint
- the endpoint.- Throws:
java.lang.IllegalStateException
-
nextProtocol
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)
.- Parameters:
connector
- the connector.endPoint
- the endpoint.buffer
- the buffer.- Throws:
java.lang.IllegalStateException
-
newConnection
public Connection newConnection(Connector connector, EndPoint endPoint)
Description copied from interface:ConnectionFactory
Creates a new
Connection
with the given parameters- Specified by:
newConnection
in interfaceConnectionFactory
- Parameters:
connector
- TheConnector
creating this connectionendPoint
- theEndPoint
associated with the connection- Returns:
- a new
Connection
-
-