Class AbstractConnector
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.AbstractConnector
-
- All Implemented Interfaces:
Connector
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
- Direct Known Subclasses:
AbstractNetworkConnector
,LocalConnector
@ManagedObject("Abstract implementation of the Connector Interface") @Deprecated(since="2021-05-27") public abstract class AbstractConnector extends ContainerLifeCycle implements Connector, Dumpable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.An abstract implementation of
Connector
that provides aConnectionFactory
mechanism for creatingConnection
instances for various protocols (HTTP, SSL, etc).Connector Services
The abstract connector manages the dependent services needed by all specific connector instances:- The
Executor
service is used to run all active tasks needed by this connector such as accepting connections or handle HTTP requests. The default is to use theServer.getThreadPool()
as an executor. - The
Scheduler
service is used to monitor the idle timeouts of all connections and is also made available to the connections to time such things as asynchronous request timeouts. The default is to use a newScheduledExecutorScheduler
instance. - The
ByteBufferPool
service is made available to all connections to be used to acquire and releaseByteBuffer
instances from a pool. The default is to use a newArrayByteBufferPool
instance.
ContainerLifeCycle
super class and may either be managed or unmanaged beans.Connection Factories
The connector keeps a collection ofConnectionFactory
instances, each of which are known by their protocol name. The protocol name may be a real protocol (e.g. "http/1.1" or "h2") or it may be a private name that represents a special connection factory. For example, the name "SSL-http/1.1" is used for anSslConnectionFactory
that has been instantiated with theHttpConnectionFactory
as it's next protocol.Configuring Connection Factories
The collection of availableConnectionFactory
may be constructor injected or modified with the methodsaddConnectionFactory(ConnectionFactory)
,removeConnectionFactory(String)
andsetConnectionFactories(Collection)
. Only a singleConnectionFactory
instance may be configured per protocol name, so if two factories with the sameConnectionFactory.getProtocol()
are set, then the second will replace the first.The protocol factory used for newly accepted connections is specified by the method
setDefaultProtocol(String)
or defaults to the protocol of the first configured factory.Each Connection factory type is responsible for the configuration of the protocols that it accepts. Thus to configure the HTTP protocol, you pass a
HttpConfiguration
instance to theHttpConnectionFactory
(or other factories that can also provide HTTP Semantics). Similarly theSslConnectionFactory
is configured by passing it aSslContextFactory
and a next protocol name.Connection Factory Operation
ConnectionFactory
s may simply create aConnection
instance to support a specific protocol. For example, theHttpConnectionFactory
will create aHttpConnection
instance that can handle http/1.1, http/1.0 and http/0.9.ConnectionFactory
s may also create a chain ofConnection
instances, using otherConnectionFactory
instances. For example, theSslConnectionFactory
is configured with a next protocol name, so that once it has accepted a connection and created anSslConnection
, it then used the nextConnectionFactory
from the connector using thegetConnectionFactory(String)
method, to create aConnection
instance that will handle the unencrypted bytes from theSslConnection
. If the next protocol is "http/1.1", then theSslConnectionFactory
will have a protocol name of "SSL-http/1.1" and lookup "http/1.1" for the protocol to run over the SSL connection.ConnectionFactory
s may also create temporaryConnection
instances that will exchange bytes over the connection to determine what is the next protocol to use. For example the ALPN protocol is an extension of SSL to allow a protocol to be specified during the SSL handshake. ALPN is used by the HTTP/2 protocol to negotiate the protocol that the client and server will speak. Thus to accept an HTTP/2 connection, the connector will be configured withConnectionFactory
s for "SSL-ALPN", "h2", "http/1.1" with the default protocol being "SSL-ALPN". Thus a newly accepted connection uses "SSL-ALPN", which specifies a SSLConnectionFactory with "ALPN" as the next protocol. Thus an SSL connection instance is created chained to an ALPN connection instance. The ALPN connection then negotiates with the client to determined the next protocol, which could be "h2" or the default of "http/1.1". Once the next protocol is determined, the ALPN connection callsgetConnectionFactory(String)
to create a connection instance that will replace the ALPN connection as the connection chained to the SSL connection.Acceptors
The connector will execute a number of acceptor tasks to theException
service passed to the constructor. The acceptor tasks run in a loop while the connector is running and repeatedly call the abstractaccept(int)
method. The implementation of the accept method must:- block waiting for new connections
- accept the connection (eg socket accept)
- perform any configuration of the connection (eg. socket configuration)
- call the
getDefaultConnectionFactory()
ConnectionFactory.newConnection(Connector, org.eclipse.jetty.io.EndPoint)
method to create a new Connection instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
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.Graceful
Graceful.Shutdown
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Constructor Summary
Constructors Constructor Description AbstractConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConnectionFactory(ConnectionFactory factory)
Deprecated.void
addFirstConnectionFactory(ConnectionFactory factory)
Deprecated.void
addIfAbsentConnectionFactory(ConnectionFactory factory)
Deprecated.void
clearConnectionFactories()
Deprecated.int
getAcceptorPriorityDelta()
Deprecated.int
getAcceptors()
Deprecated.ByteBufferPool
getByteBufferPool()
Deprecated.java.util.Collection<EndPoint>
getConnectedEndPoints()
Deprecated.java.util.Collection<ConnectionFactory>
getConnectionFactories()
Deprecated.<T> T
getConnectionFactory(java.lang.Class<T> factoryType)
Deprecated.ConnectionFactory
getConnectionFactory(java.lang.String protocol)
Deprecated.ConnectionFactory
getDefaultConnectionFactory()
Deprecated.java.lang.String
getDefaultProtocol()
Deprecated.java.util.concurrent.Executor
getExecutor()
Deprecated.HttpChannel.Listener
getHttpChannelListeners()
Deprecated.Get theHttpChannel.Listener
s added to the connector as a single combined Listener.long
getIdleTimeout()
Deprecated.java.lang.String
getName()
Deprecated.Get the connector name if set.java.util.List<java.lang.String>
getProtocols()
Deprecated.Scheduler
getScheduler()
Deprecated.Server
getServer()
Deprecated.boolean
isAccepting()
Deprecated.boolean
isShutdown()
Deprecated.void
join()
Deprecated.void
join(long timeout)
Deprecated.ConnectionFactory
removeConnectionFactory(java.lang.String protocol)
Deprecated.void
setAccepting(boolean accepting)
Deprecated.void
setAcceptorPriorityDelta(int acceptorPriorityDelta)
Deprecated.Set the acceptor thread priority delta.void
setConnectionFactories(java.util.Collection<ConnectionFactory> factories)
Deprecated.void
setDefaultProtocol(java.lang.String defaultProtocol)
Deprecated.void
setIdleTimeout(long idleTimeout)
Deprecated.Sets the maximum Idle time for a connection, which roughly translates to theSocket.setSoTimeout(int)
call, although with NIO implementations other mechanisms may be used to implement the timeout.void
setName(java.lang.String name)
Deprecated.Set a connector name.java.util.concurrent.Future<java.lang.Void>
shutdown()
Deprecated.java.lang.String
toString()
Deprecated.-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.server.Connector
getTransport
-
Methods inherited from interface org.eclipse.jetty.util.component.Container
addBean, addBean, addEventListener, getBean, getBeans, getBeans, getContainedBeans, isManaged, manage, removeBean, removeEventListener, unmanage
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Constructor Detail
-
AbstractConnector
public AbstractConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
Deprecated.- Parameters:
server
- The server this connector will be added to. Must not be null.executor
- An executor for this connector or null to use the servers executorscheduler
- A scheduler for this connector or null to either aScheduler
set as a server bean or if none set, then a newScheduledExecutorScheduler
instance.pool
- A buffer pool for this connector or null to either aByteBufferPool
set as a server bean or none set, the newArrayByteBufferPool
instance.acceptors
- the number of acceptor threads to use, or -1 for a default value. If 0, then no acceptor threads will be launched and some other mechanism will need to be used to accept new connections.factories
- The Connection Factories to use.
-
-
Method Detail
-
getHttpChannelListeners
public HttpChannel.Listener getHttpChannelListeners()
Deprecated.Get theHttpChannel.Listener
s added to the connector as a single combined Listener. This is equivalent to a listener that iterates over the individual listeners returned fromgetBeans(HttpChannel.Listener.class);
, except that:- The result is precomputed, so it is more efficient
- The result is ordered by the order added.
- The result is immutable.
- Returns:
- An unmodifiable list of EventListener beans
- See Also:
ContainerLifeCycle.getBeans(Class)
-
getServer
public Server getServer()
Deprecated.
-
getExecutor
public java.util.concurrent.Executor getExecutor()
Deprecated.- Specified by:
getExecutor
in interfaceConnector
- Returns:
- the
Executor
used to submit tasks
-
getByteBufferPool
public ByteBufferPool getByteBufferPool()
Deprecated.- Specified by:
getByteBufferPool
in interfaceConnector
- Returns:
- the
ByteBufferPool
to acquire buffers from and release buffers to
-
getIdleTimeout
@ManagedAttribute("The connection idle timeout in milliseconds") public long getIdleTimeout()
Deprecated.- Specified by:
getIdleTimeout
in interfaceConnector
- Returns:
- the max idle timeout for connections in milliseconds
-
setIdleTimeout
public void setIdleTimeout(long idleTimeout)
Deprecated.Sets the maximum Idle time for a connection, which roughly translates to the
Socket.setSoTimeout(int)
call, although with NIO implementations other mechanisms may be used to implement the timeout.The max idle time is applied:
- When waiting for a new message to be received on a connection
- When waiting for a new message to be sent on a connection
This value is interpreted as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout is reset.
- Parameters:
idleTimeout
- the idle timeout
-
getAcceptors
@ManagedAttribute("number of acceptor threads") public int getAcceptors()
Deprecated.- Returns:
- Returns the number of acceptor threads.
-
shutdown
public java.util.concurrent.Future<java.lang.Void> shutdown()
Deprecated.
-
isShutdown
public boolean isShutdown()
Deprecated.- Specified by:
isShutdown
in interfaceGraceful
-
join
public void join() throws java.lang.InterruptedException
Deprecated.- Throws:
java.lang.InterruptedException
-
join
public void join(long timeout) throws java.lang.InterruptedException
Deprecated.- Throws:
java.lang.InterruptedException
-
isAccepting
public boolean isAccepting()
Deprecated.- Returns:
- Is the connector accepting new connections
-
setAccepting
public void setAccepting(boolean accepting)
Deprecated.
-
getConnectionFactory
public ConnectionFactory getConnectionFactory(java.lang.String protocol)
Deprecated.- Specified by:
getConnectionFactory
in interfaceConnector
- Parameters:
protocol
- the next protocol- Returns:
- the
ConnectionFactory
associated with the protocol name
-
getConnectionFactory
public <T> T getConnectionFactory(java.lang.Class<T> factoryType)
Deprecated.- Specified by:
getConnectionFactory
in interfaceConnector
-
addConnectionFactory
public void addConnectionFactory(ConnectionFactory factory)
Deprecated.
-
addFirstConnectionFactory
public void addFirstConnectionFactory(ConnectionFactory factory)
Deprecated.
-
addIfAbsentConnectionFactory
public void addIfAbsentConnectionFactory(ConnectionFactory factory)
Deprecated.
-
removeConnectionFactory
public ConnectionFactory removeConnectionFactory(java.lang.String protocol)
Deprecated.
-
getConnectionFactories
public java.util.Collection<ConnectionFactory> getConnectionFactories()
Deprecated.- Specified by:
getConnectionFactories
in interfaceConnector
-
setConnectionFactories
public void setConnectionFactories(java.util.Collection<ConnectionFactory> factories)
Deprecated.
-
getAcceptorPriorityDelta
@ManagedAttribute("The priority delta to apply to acceptor threads") public int getAcceptorPriorityDelta()
Deprecated.
-
setAcceptorPriorityDelta
public void setAcceptorPriorityDelta(int acceptorPriorityDelta)
Deprecated.Set the acceptor thread priority delta.This allows the acceptor thread to run at a different priority. Typically this would be used to lower the priority to give preference to handling previously accepted connections rather than accepting new connections
- Parameters:
acceptorPriorityDelta
- the acceptor priority delta
-
getProtocols
@ManagedAttribute("Protocols supported by this connector") public java.util.List<java.lang.String> getProtocols()
Deprecated.- Specified by:
getProtocols
in interfaceConnector
-
clearConnectionFactories
public void clearConnectionFactories()
Deprecated.
-
getDefaultProtocol
@ManagedAttribute("This connector\'s default protocol") public java.lang.String getDefaultProtocol()
Deprecated.
-
setDefaultProtocol
public void setDefaultProtocol(java.lang.String defaultProtocol)
Deprecated.
-
getDefaultConnectionFactory
public ConnectionFactory getDefaultConnectionFactory()
Deprecated.- Specified by:
getDefaultConnectionFactory
in interfaceConnector
- Returns:
- the default
ConnectionFactory
associated with the default protocol name
-
getConnectedEndPoints
public java.util.Collection<EndPoint> getConnectedEndPoints()
Deprecated.- Specified by:
getConnectedEndPoints
in interfaceConnector
- Returns:
- immutable collection of connected endpoints
-
getScheduler
public Scheduler getScheduler()
Deprecated.- Specified by:
getScheduler
in interfaceConnector
- Returns:
- the
Scheduler
used to schedule tasks
-
getName
public java.lang.String getName()
Deprecated.Description copied from interface:Connector
Get the connector name if set.A
ContextHandler
may be configured with virtual hosts in the form "@connectorName" and will only serve requests from the named connector.
-
setName
public void setName(java.lang.String name)
Deprecated.Set a connector name. A context may be configured with virtual hosts in the form "@contextname" and will only serve requests from the named connector,- Parameters:
name
- A connector name.
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classAbstractLifeCycle
-
-