org.springframework.integration.ip.tcp
Class TcpNetReceivingChannelAdapter

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.endpoint.MessageProducerSupport
              extended by org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
                  extended by org.springframework.integration.ip.tcp.AbstractTcpReceivingChannelAdapter
                      extended by org.springframework.integration.ip.tcp.TcpNetReceivingChannelAdapter
All Implemented Interfaces:
java.lang.Runnable, 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, MessageProducer, CommonSocketOptions

public class TcpNetReceivingChannelAdapter
extends AbstractTcpReceivingChannelAdapter

Tcp Receiving Channel adapter that uses a Socket. Each connected socket uses a dedicated thread so the pool size must be set accordingly.

Author:
Gary Russell

Field Summary
protected  java.lang.Class<NetSocketReader> customSocketReaderClass
           
protected  java.net.ServerSocket serverSocket
           
 
Fields inherited from class org.springframework.integration.ip.tcp.AbstractTcpReceivingChannelAdapter
mapper, messageFormat, poolSize, soKeepAlive, threadPoolTaskScheduler
 
Fields inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
active, port, receiveBufferSize, soReceiveBufferSize, soTimeout
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
TcpNetReceivingChannelAdapter(int port)
          Constructs a TcpNetReceivingChannelAdapter that listens on the port.
 
Method Summary
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected  void handleSocket(java.net.Socket socket)
          Constructs a NetSocketReader and calls its AbstractSocketReader.assembledData method repeatedly; for each assembled message, calls MessageProducerSupport.sendMessage(Message) with the mapped message.
protected  void processMessage(NetSocketReader reader)
           
protected  void server()
          Creates the server socket, listens for incoming connections and schedules execution of the handleSocket(Socket) method for each new connection.
 void setCustomSocketReaderClassName(java.lang.String customSocketReaderClassName)
           
 
Methods inherited from class org.springframework.integration.ip.tcp.AbstractTcpReceivingChannelAdapter
run, setMessageFormat, setPoolSize, setSocketOptions, setSoKeepAlive
 
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
doStart, getPort, setReceiveBufferSize, setSoReceiveBufferSize, setSoSendBufferSize, setSoTimeout
 
Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
onInit, sendMessage, setOutputChannel, setSendTimeout
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getChannelResolver, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setChannelResolver, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serverSocket

protected java.net.ServerSocket serverSocket

customSocketReaderClass

protected java.lang.Class<NetSocketReader> customSocketReaderClass
Constructor Detail

TcpNetReceivingChannelAdapter

public TcpNetReceivingChannelAdapter(int port)
Constructs a TcpNetReceivingChannelAdapter that listens on the port.

Parameters:
port - The port.
Method Detail

server

protected void server()
Creates the server socket, listens for incoming connections and schedules execution of the handleSocket(Socket) method for each new connection.

Specified by:
server in class AbstractTcpReceivingChannelAdapter
See Also:
AbstractTcpReceivingChannelAdapter.server()

handleSocket

protected void handleSocket(java.net.Socket socket)
Constructs a NetSocketReader and calls its AbstractSocketReader.assembledData method repeatedly; for each assembled message, calls MessageProducerSupport.sendMessage(Message) with the mapped message.

Parameters:
socket -

processMessage

protected void processMessage(NetSocketReader reader)
                       throws java.lang.Exception
Parameters:
reader -
Throws:
java.lang.Exception

doStop

protected void doStop()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Overrides:
doStop in class AbstractInternetProtocolReceivingChannelAdapter

setCustomSocketReaderClassName

public void setCustomSocketReaderClassName(java.lang.String customSocketReaderClassName)
                                    throws java.lang.ClassNotFoundException
Parameters:
customSocketReaderClass - the customSocketReader to set
Throws:
java.lang.ClassNotFoundException