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, Lifecycle, Phased, SmartLifecycle, Ordered, NamedComponent, Orderable, MessageHandler, TrackableComponent, TcpSender

public class TcpSendingMessageHandler
extends AbstractMessageHandler
implements TcpSender, SmartLifecycle

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  org.apache.commons.logging.Log logger
           
 
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 doWrite(Message<?> message)
          Method that actually does the write.
protected  ConnectionFactory getClientConnectionFactory()
           
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
protected  TcpConnection getConnection()
           
protected  java.util.Map<java.lang.String,TcpConnection> getConnections()
           
 int getPhase()
           
protected  ConnectionFactory getServerConnectionFactory()
           
 void handleMessageInternal(Message<?> message)
          Writes the message payload to the underlying socket, using the specified message format.
 boolean isAutoStartup()
           
 boolean isRunning()
           
 void removeDeadConnection(TcpConnection connection)
          When we are using sockets owned by a TcpListener, this method is called each time a connection is closed.
 void setAutoStartup(boolean autoStartup)
           
 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.
 void setPhase(int phase)
           
 void start()
           
 void stop()
           
 void stop(java.lang.Runnable callback)
           
 
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 final org.apache.commons.logging.Log logger
Constructor Detail

TcpSendingMessageHandler

public TcpSendingMessageHandler()
Method Detail

getConnection

protected TcpConnection getConnection()

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

start

public void start()
Specified by:
start in interface Lifecycle

stop

public void stop()
Specified by:
stop in interface Lifecycle

isRunning

public boolean isRunning()
Specified by:
isRunning in interface Lifecycle

getPhase

public int getPhase()
Specified by:
getPhase in interface Phased

isAutoStartup

public boolean isAutoStartup()
Specified by:
isAutoStartup in interface SmartLifecycle

stop

public void stop(java.lang.Runnable callback)
Specified by:
stop in interface SmartLifecycle

setAutoStartup

public void setAutoStartup(boolean autoStartup)

setPhase

public void setPhase(int phase)

getClientConnectionFactory

protected ConnectionFactory getClientConnectionFactory()
Returns:
the clientConnectionFactory

getServerConnectionFactory

protected ConnectionFactory getServerConnectionFactory()
Returns:
the serverConnectionFactory

getConnections

protected java.util.Map<java.lang.String,TcpConnection> getConnections()
Returns:
the connections