Spring Integration

org.springframework.integration.ip.tcp.connection
Class TcpMessageMapper

java.lang.Object
  extended by org.springframework.integration.ip.tcp.connection.TcpMessageMapper
All Implemented Interfaces:
InboundMessageMapper<TcpConnection>, OutboundMessageMapper<java.lang.Object>
Direct Known Subclasses:
MessageConvertingTcpMessageMapper

public class TcpMessageMapper
extends java.lang.Object
implements InboundMessageMapper<TcpConnection>, OutboundMessageMapper<java.lang.Object>

Maps incoming data from a TcpConnection to a Message. If StringToBytes is true (default), payloads of type String are converted to a byte[] using the supplied charset (UTF-8 by default). Inbound messages include headers representing the remote end of the connection as well as a connection id that can be used by a TcpSender to correlate which connection to send a reply. If applySequence is set, adds standard correlationId/sequenceNumber headers allowing for downstream (unbounded) resequencing.

Since:
2.0
Author:
Gary Russell

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
TcpMessageMapper()
           
 
Method Summary
protected  void addCustomHeaders(TcpConnection connection, MessageBuilder<?> messageBuilder)
           
protected  void addStandardHeaders(TcpConnection connection, MessageBuilder<?> messageBuilder)
           
 java.lang.Object fromMessage(Message<?> message)
           
 void setApplySequence(boolean applySequence)
           
 void setCharset(java.lang.String charset)
           
 void setStringToBytes(boolean stringToBytes)
          Sets whether outbound String payloads are to be converted to byte[].
protected  java.util.Map<java.lang.String,?> supplyCustomHeaders(TcpConnection connection)
          Override to provide additional headers.
 Message<java.lang.Object> toMessage(TcpConnection connection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

TcpMessageMapper

public TcpMessageMapper()
Method Detail

toMessage

public Message<java.lang.Object> toMessage(TcpConnection connection)
                                    throws java.lang.Exception
Specified by:
toMessage in interface InboundMessageMapper<TcpConnection>
Throws:
java.lang.Exception

addStandardHeaders

protected final void addStandardHeaders(TcpConnection connection,
                                        MessageBuilder<?> messageBuilder)

addCustomHeaders

protected final void addCustomHeaders(TcpConnection connection,
                                      MessageBuilder<?> messageBuilder)

supplyCustomHeaders

protected java.util.Map<java.lang.String,?> supplyCustomHeaders(TcpConnection connection)
Override to provide additional headers. The standard headers cannot be overridden and any such headers will be ignored if provided in the result.

Parameters:
connection - the connection.
Returns:
A Map of <String, ?> headers to be added to the message.

fromMessage

public java.lang.Object fromMessage(Message<?> message)
                             throws java.lang.Exception
Specified by:
fromMessage in interface OutboundMessageMapper<java.lang.Object>
Throws:
java.lang.Exception

setCharset

public void setCharset(java.lang.String charset)
Parameters:
charset - the charset to set

setStringToBytes

public void setStringToBytes(boolean stringToBytes)
Sets whether outbound String payloads are to be converted to byte[]. Default is true.

Parameters:
stringToBytes -

setApplySequence

public void setApplySequence(boolean applySequence)
Parameters:
applySequence - the applySequence to set

Spring Integration