org.springframework.integration.ip.udp
Class UnicastReceivingChannelAdapter

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.udp.UnicastReceivingChannelAdapter
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, MessageProducer, CommonSocketOptions, ComponentMetadataProvider
Direct Known Subclasses:
MulticastReceivingChannelAdapter

public class UnicastReceivingChannelAdapter
extends AbstractInternetProtocolReceivingChannelAdapter

A channel adapter to receive incoming UDP packets. Packets can optionally be preceded by a 4 byte length field, used to validate that all data was received. Packets may also contain information indicating an acknowledgment needs to be sent.

Since:
2.0
Author:
Gary Russell

Field Summary
protected  DatagramPacketMessageMapper mapper
           
protected  int poolSize
           
protected  java.net.DatagramSocket socket
           
protected  int soSendBufferSize
           
protected  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler 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
UnicastReceivingChannelAdapter(int port)
          Constructs a UnicastReceivingChannelAdapter that listens on the specified port.
UnicastReceivingChannelAdapter(int port, boolean lengthCheck)
          Constructs a UnicastReceivingChannelAdapter that listens for packets on the specified port.
 
Method Summary
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected  java.net.DatagramSocket getSocket()
           
protected  java.net.DatagramPacket receive()
           
 void run()
           
protected  boolean scheduleSendMessage(java.net.DatagramPacket packet)
           
protected  void sendAck(Message<byte[]> message)
           
 void setPoolSize(int poolSize)
           
 void setSoSendBufferSize(int soSendBufferSize)
           
 
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter
doStart, getPort, setReceiveBufferSize, setSoReceiveBufferSize, 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, getBeanName, getChannelResolver, getComponentMetadata, getConversionService, getTaskScheduler, populateComponentMetadata, setBeanFactory, setBeanName, setChannelResolver, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected volatile java.net.DatagramSocket socket

mapper

protected final DatagramPacketMessageMapper mapper

threadPoolTaskScheduler

protected volatile org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler threadPoolTaskScheduler

poolSize

protected volatile int poolSize

soSendBufferSize

protected volatile int soSendBufferSize
Constructor Detail

UnicastReceivingChannelAdapter

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

Parameters:
port -

UnicastReceivingChannelAdapter

public UnicastReceivingChannelAdapter(int port,
                                      boolean lengthCheck)
Constructs a UnicastReceivingChannelAdapter that listens for packets on the specified port. Enables setting the lengthCheck option, which expects a length to precede the incoming packets.

Parameters:
port - The port.
lengthCheck - If true, enables the lengthCheck Option.
Method Detail

setPoolSize

public void setPoolSize(int poolSize)

run

public void run()

sendAck

protected void sendAck(Message<byte[]> message)

scheduleSendMessage

protected boolean scheduleSendMessage(java.net.DatagramPacket packet)

receive

protected java.net.DatagramPacket receive()
                                   throws java.lang.Exception
Throws:
java.lang.Exception

getSocket

protected java.net.DatagramSocket getSocket()

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

setSoSendBufferSize

public void setSoSendBufferSize(int soSendBufferSize)
Specified by:
setSoSendBufferSize in interface CommonSocketOptions
Overrides:
setSoSendBufferSize in class AbstractInternetProtocolReceivingChannelAdapter