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<Object>

public class TcpMessageMapper
extends Object
implements InboundMessageMapper<TcpConnection>, OutboundMessageMapper<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.

Since:
2.0
Author:
Gary Russell

Constructor Summary
TcpMessageMapper()
           
 
Method Summary
 Object fromMessage(Message<?> message)
           
 void setCharset(String charset)
           
 void setStringToBytes(boolean stringToBytes)
          Sets whether outbound String payloads are to be converted to byte[].
 Message<Object> toMessage(TcpConnection connection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpMessageMapper

public TcpMessageMapper()
Method Detail

toMessage

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

fromMessage

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

setCharset

public void setCharset(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 -

Spring Integration

Copyright © 2010. All Rights Reserved.