org.springframework.integration.ip.tcp
Class TcpSendingMessageHandler

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.ip.tcp.TcpSendingMessageHandler
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, Orderable, MessageHandler, TrackableComponent, TcpSender

public class TcpSendingMessageHandler
extends AbstractMessageHandler
implements TcpSender

Tcp outbound channel adapter using a TcpConnection to send data - if the connection factory is a server factory, the TcpListener owns the connections. If it is a client factory, this object owns the connection.

Since:
2.0

Field Summary
protected  ConnectionFactory clientConnectionFactory
           
protected  TcpConnection connection
           
protected  java.util.Map<java.lang.String,TcpConnection> connections
           
protected  org.apache.commons.logging.Log logger
           
protected  ConnectionFactory serverConnectionFactory
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
TcpSendingMessageHandler()
           
 
Method Summary
 void addNewConnection(TcpConnection connection)
          When we are using sockets owned by a TcpListener, this method is called each time a new connection is made.
protected  void close()
          Close the underlying socket and prepare to establish a new socket on the next write.
protected  void doWrite(Message<?> message)
          Method that actually does the write.
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
protected  TcpConnection getConnection()
           
 void handleMessageInternal(Message<?> message)
          Writes the message payload to the underlying socket, using the specified message format.
 void removeDeadConnection(TcpConnection connection)
          When we are using sockets owned by a TcpListener, this method is called each time a connection is closed.
 void setConnectionFactory(AbstractConnectionFactory connectionFactory)
          Sets the client or server connection factory; for this (an outbound adapter), if the factory is a server connection factory, the sockets are owned by a receiving channel adapter and this adapter is used to send replies.
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, setOrder, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, 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
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Field Detail

logger

protected org.apache.commons.logging.Log logger

connection

protected TcpConnection connection

clientConnectionFactory

protected ConnectionFactory clientConnectionFactory

serverConnectionFactory

protected ConnectionFactory serverConnectionFactory

connections

protected java.util.Map<java.lang.String,TcpConnection> connections
Constructor Detail

TcpSendingMessageHandler

public TcpSendingMessageHandler()
Method Detail

getConnection

protected TcpConnection getConnection()

close

protected void close()
Close the underlying socket and prepare to establish a new socket on the next write.


handleMessageInternal

public void handleMessageInternal(Message<?> message)
                           throws MessageRejectedException,
                                  MessageHandlingException,
                                  MessageDeliveryException
Writes the message payload to the underlying socket, using the specified message format.

Specified by:
handleMessageInternal in class AbstractMessageHandler
Throws:
MessageRejectedException
MessageHandlingException
MessageDeliveryException
See Also:
MessageHandler.handleMessage(org.springframework.integration.Message)

doWrite

protected void doWrite(Message<?> message)
Method that actually does the write.

Parameters:
message - The message to write.

setConnectionFactory

public void setConnectionFactory(AbstractConnectionFactory connectionFactory)
Sets the client or server connection factory; for this (an outbound adapter), if the factory is a server connection factory, the sockets are owned by a receiving channel adapter and this adapter is used to send replies.

Parameters:
connectionFactory - the connectionFactory to set

addNewConnection

public void addNewConnection(TcpConnection connection)
Description copied from interface: TcpSender
When we are using sockets owned by a TcpListener, this method is called each time a new connection is made.

Specified by:
addNewConnection in interface TcpSender
Parameters:
connection - The connection.

removeDeadConnection

public void removeDeadConnection(TcpConnection connection)
Description copied from interface: TcpSender
When we are using sockets owned by a TcpListener, this method is called each time a connection is closed.

Specified by:
removeDeadConnection in interface TcpSender
Parameters:
connection - The connection.

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class AbstractMessageHandler