org.springframework.integration.ip.tcp.connection
Class TcpNetServerConnectionFactory
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.TcpNetServerConnectionFactory
- 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 TcpNetServerConnectionFactory
- extends AbstractServerConnectionFactory
Implements a server connection factory that produces TcpNetConnection
s using
a ServerSocket
. 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, doAccept, 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 |
TcpNetServerConnectionFactory
public TcpNetServerConnectionFactory(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.
createServerSocket
protected java.net.ServerSocket createServerSocket(int port,
int backlog,
java.net.InetAddress whichNic)
throws java.io.IOException
- Create a new
ServerSocket
. This default implementation uses the default
ServerSocketFactory
. Override to use some other mechanism
- Parameters:
port
- The port.backlog
- The server socket backlog.whichNic
- An InetAddress if binding to a specific network interface. Set to
null when configured to bind to all interfaces.
- Returns:
- The Server Socket.
- Throws:
java.io.IOException
close
public void close()
- Description copied from class:
AbstractConnectionFactory
- Closes the server.
- Specified by:
close
in class AbstractConnectionFactory
getServerSocket
protected java.net.ServerSocket getServerSocket()
- Returns:
- the serverSocket
getTcpSocketFactorySupport
protected TcpSocketFactorySupport getTcpSocketFactorySupport()
setTcpSocketFactorySupport
public void setTcpSocketFactorySupport(TcpSocketFactorySupport tcpSocketFactorySupport)