Spring Integration

org.springframework.integration.ip.tcp
Class AbstractTcpSendingMessageHandler

java.lang.Object
  extended by org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler
      extended by org.springframework.integration.ip.tcp.AbstractTcpSendingMessageHandler
All Implemented Interfaces:
MessageHandler, CommonSocketOptions
Direct Known Subclasses:
TcpNetSendingMessageHandler, TcpNioSendingMessageHandler

public abstract class AbstractTcpSendingMessageHandler
extends AbstractInternetProtocolSendingMessageHandler

Abstract class for TCP sending message handlers. Implementations for Socket and SocketChannel are provided.

Author:
Gary Russell

Field Summary
protected  SocketMessageMapper mapper
           
protected  int messageFormat
           
protected  boolean soKeepAlive
           
protected  int soLinger
           
protected  boolean soTcpNoDelay
           
protected  int soTrafficClass
           
protected  AbstractSocketWriter writer
           
 
Fields inherited from class org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler
destinationAddress, host, logger, port, soSendBufferSize, soTimeout
 
Constructor Summary
AbstractTcpSendingMessageHandler(String host, int port)
          Constructs a message handler that sends messages to the specified host and port.
 
Method Summary
protected  void doWrite(Message<?> message)
          Method that actually does the write.
protected abstract  SocketWriter getWriter()
          Returns the socket writer after instantiating it, if necessary.
 void handleMessage(Message<?> message)
          Writes the message payload to the underlying socket, using the specified message format.
 void setMessageFormat(int messageFormat)
           
protected  void setSocketAttributes(Socket socket)
          Sets socket attributes on the socket.
 void setSoKeepAlive(boolean soKeepAlive)
           
 void setSoLinger(int soLinger)
          Enables SO_LINGER on the underlying socket.
 void setSoTcpNoDelay(boolean soTcpNoDelay)
           
 void setSoTrafficClass(int soTrafficClass)
           
 
Methods inherited from class org.springframework.integration.ip.AbstractInternetProtocolSendingMessageHandler
getPort, setSoReceiveBufferSize, setSoSendBufferSize, setSoTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.ip.CommonSocketOptions
setLocalAddress
 

Field Detail

mapper

protected SocketMessageMapper mapper

writer

protected AbstractSocketWriter writer

soTcpNoDelay

protected boolean soTcpNoDelay

soLinger

protected int soLinger

soTrafficClass

protected int soTrafficClass

soKeepAlive

protected boolean soKeepAlive

messageFormat

protected int messageFormat
Constructor Detail

AbstractTcpSendingMessageHandler

public AbstractTcpSendingMessageHandler(String host,
                                        int port)
Constructs a message handler that sends messages to the specified host and port.

Parameters:
host - The host.
port - The port.
Method Detail

setSocketAttributes

protected void setSocketAttributes(Socket socket)
                            throws SocketException
Sets socket attributes on the socket.

Parameters:
socket - The socket.
Throws:
SocketException

getWriter

protected abstract SocketWriter getWriter()
Returns the socket writer after instantiating it, if necessary.

Returns:
The writer.

handleMessage

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

Parameters:
message - the message to be handled
Throws:
MessageRejectedException - if the handler doesn't select these types of messages
MessageHandlingException - when something went wrong during the handling
MessageDeliveryException - when this handler failed to deliver the reply related to the handling of the message
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.

setSoTcpNoDelay

public void setSoTcpNoDelay(boolean soTcpNoDelay)
Parameters:
soTcpNoDelay - the soTcpNoDelay to set
See Also:
Socket.setTcpNoDelay(boolean)

setSoLinger

public void setSoLinger(int soLinger)
Enables SO_LINGER on the underlying socket.

Parameters:
soLinger - the soLinger to set
See Also:
Socket.setSoLinger(boolean, int)

setSoTrafficClass

public void setSoTrafficClass(int soTrafficClass)
Parameters:
soTrafficClass - the soTrafficClass to set
See Also:
Socket.setTrafficClass(int)

setSoKeepAlive

public void setSoKeepAlive(boolean soKeepAlive)
Parameters:
soKeepAlive - the soKeepAlive to set
See Also:
Socket.setKeepAlive(boolean)

setMessageFormat

public void setMessageFormat(int messageFormat)
Parameters:
messageFormat - the messageFormat to set
See Also:
MessageFormats

Spring Integration

Copyright © 2010. All Rights Reserved.