org.springframework.integration.ip.tcp.connection
Class TcpNioServerConnectionFactory
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory
org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory
- All Implemented Interfaces:
- java.lang.Runnable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, NamedComponent, OrderlyShutdownCapable, ConnectionFactory
public class TcpNioServerConnectionFactory
- extends AbstractServerConnectionFactory
/**
Implements a server connection factory that produces TcpNioConnection
s using
a ServerSocketChannel
. Must have a TcpListener
registered.
- Since:
- 2.0
- Author:
- Gary Russell
Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory |
afterShutdown, beforeShutdown, getBacklog, getConnection, getLocalAddress, initializeConnection, isListening, isShuttingDown, postProcessServerSocket, setBacklog, setListening, setLocalAddress, setPoolSize, start |
Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory |
addConnection, checkActive, getDeserializer, getHost, getListener, getMapper, getPhase, getPoolSize, getPort, getSender, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isAutoStartup, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, processNioSelections, registerListener, registerSender, setActive, setDeserializer, setInterceptorFactoryChain, setLookupHost, setMapper, setNioHarvestInterval, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setTaskExecutor, setTcpSocketSupport, stop, stop, wrapConnection |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TcpNioServerConnectionFactory
public TcpNioServerConnectionFactory(int port)
- Listens for incoming connections on the port.
- Parameters:
port
- The port.
run
public void run()
- If no listener registers, exits.
Accepts incoming connections and creates TcpConnections for each new connection.
Invokes {
AbstractServerConnectionFactory.initializeConnection(TcpConnection, 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.
doAccept
protected void doAccept(java.nio.channels.Selector selector,
java.nio.channels.ServerSocketChannel server,
long now)
throws java.io.IOException
- Overrides:
doAccept
in class AbstractConnectionFactory
- Parameters:
selector
- server
- now
-
- Throws:
java.io.IOException
java.net.SocketException
java.nio.channels.ClosedChannelException
close
public void close()
- Description copied from class:
AbstractConnectionFactory
- Closes the server.
- Specified by:
close
in class AbstractConnectionFactory
setUsingDirectBuffers
public void setUsingDirectBuffers(boolean usingDirectBuffers)
setTcpNioConnectionSupport
public void setTcpNioConnectionSupport(TcpNioConnectionSupport tcpNioSupport)
getServerChannel
protected java.nio.channels.ServerSocketChannel getServerChannel()
- Returns:
- the serverChannel
isUsingDirectBuffers
protected boolean isUsingDirectBuffers()
- Returns:
- the usingDirectBuffers
getConnections
protected java.util.Map<java.nio.channels.SocketChannel,TcpNioConnection> getConnections()
- Returns:
- the connections