Spring Integration

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:
Runnable, BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, MessageProducer, NamedComponent, 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.

Since:
2.0
Author:
Gary Russell

Field Summary
protected  Class<NetSocketReader> customSocketReaderClass
           
protected  ServerSocket serverSocket
           
 
Fields inherited from class org.springframework.integration.ip.tcp.AbstractTcpReceivingChannelAdapter
close, mapper, messageFormat, soKeepAlive
 
Fields inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
active, listening, localAddress, poolSize, port, receiveBufferSize, soReceiveBufferSize, soTimeout, taskExecutor
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
TcpNetReceivingChannelAdapter(int port)
          Constructs a TcpNetReceivingChannelAdapter that listens on the provided port.
 
Method Summary
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected  void handleSocket(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(String customSocketReaderClassName)
           
 
Methods inherited from class org.springframework.integration.ip.tcp.AbstractTcpReceivingChannelAdapter
run, setClose, setMessageFormat, setSocketOptions, setSoKeepAlive
 
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
checkTaskExecutor, doStart, getLocalAddress, getPort, isListening, setLocalAddress, setPoolSize, setReceiveBufferSize, setSoReceiveBufferSize, setSoSendBufferSize, setSoTimeout, setTaskExecutor
 
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, setComponentName, setConversionService, toString, writeMessageHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serverSocket

protected ServerSocket serverSocket

customSocketReaderClass

protected Class<NetSocketReader> customSocketReaderClass
Constructor Detail

TcpNetReceivingChannelAdapter

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

Parameters:
port - the port on which to listen
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(Socket socket)
Constructs a NetSocketReader and calls its AbstractSocketReader.assembledData method repeatedly; for each assembled message, calls MessageProducerSupport.sendMessage(Message) with the mapped message.


processMessage

protected void processMessage(NetSocketReader reader)
                       throws Exception
Throws:
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(String customSocketReaderClassName)
                                    throws ClassNotFoundException
Parameters:
customSocketReaderClassName - the NetSocketReader class to use
Throws:
ClassNotFoundException - if the named class cannot be loaded

Spring Integration

Copyright © 2010. All Rights Reserved.