public class TcpNioServerConnectionFactory extends AbstractServerConnectionFactory
TcpNioConnection
s using
a ServerSocketChannel
. Must have a TcpListener
registered.DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
EXPRESSION_PARSER, logger
Constructor and Description |
---|
TcpNioServerConnectionFactory(int port)
Listens for incoming connections on the port.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doAccept(Selector selectorForNewSocket,
ServerSocketChannel server,
long now) |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
protected Map<SocketChannel,TcpNioConnection> |
getConnections() |
int |
getPort()
Return the port this server is listening on.
|
protected ServerSocketChannel |
getServerChannel() |
SocketAddress |
getServerSocketAddress()
Return the
SocketAddress that the underlying ServerSocket
is bound to. |
protected boolean |
isUsingDirectBuffers() |
void |
run()
If no listener registers, exits.
|
void |
setMultiAccept(boolean multiAccept)
Set to false to only accept one connection per iteration over the
selector keys.
|
void |
setTcpNioConnectionSupport(TcpNioConnectionSupport tcpNioSupport) |
void |
setUsingDirectBuffers(boolean usingDirectBuffers) |
void |
stop()
Stops the server.
|
afterShutdown, beforeShutdown, getBacklog, getConnection, getLocalAddress, initializeConnection, isListening, isLongLived, isShuttingDown, postProcessServerSocket, publishServerExceptionEvent, publishServerListeningEvent, setBacklog, setListening, setLocalAddress, start
addConnection, checkActive, closeConnection, delayRead, getApplicationEventPublisher, getDelayedReads, getDeserializer, getHost, getLifecycleMonitor, getListener, getMapper, getOpenConnectionIds, getReadDelay, getSender, getSenders, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, onInit, processNioSelections, registerListener, registerSender, setActive, setApplicationEventPublisher, setDeserializer, setHost, setInterceptorFactoryChain, setLeaveOpen, setLookupHost, setMapper, setNioHarvestInterval, setPort, setReadDelay, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setSslHandshakeTimeout, setTaskExecutor, setTcpSocketSupport, toString, unregisterSender, wrapConnection
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler
public TcpNioServerConnectionFactory(int port)
port
- The port.public void setMultiAccept(boolean multiAccept)
OP_ACCEPT
operation
is ready, we will keep accepting connections in a loop until no more arrive.multiAccept
- false to accept connections one-at-a-time.public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public int getPort()
TcpServerConnectionFactory
getPort
in interface TcpServerConnectionFactory
getPort
in class AbstractConnectionFactory
@Nullable public SocketAddress getServerSocketAddress()
TcpServerConnectionFactory
SocketAddress
that the underlying ServerSocket
is bound to.getServerSocketAddress
in interface TcpServerConnectionFactory
getServerSocketAddress
in class AbstractServerConnectionFactory
public void run()
AbstractServerConnectionFactory.initializeConnection(TcpConnectionSupport, Socket)
and executes the
connection Runnable.run()
using the task executor.
I/O errors on the server socket/channel are logged and the factory is stopped.protected void doAccept(Selector selectorForNewSocket, ServerSocketChannel server, long now)
doAccept
in class AbstractConnectionFactory
selectorForNewSocket
- The selector.server
- The server socket channel.now
- The current time.public void stop()
AbstractConnectionFactory
stop
in interface Lifecycle
stop
in interface ManageableLifecycle
stop
in class AbstractConnectionFactory
public void setUsingDirectBuffers(boolean usingDirectBuffers)
public void setTcpNioConnectionSupport(TcpNioConnectionSupport tcpNioSupport)
protected ServerSocketChannel getServerChannel()
protected boolean isUsingDirectBuffers()
protected Map<SocketChannel,TcpNioConnection> getConnections()