public class TcpMessageMapper extends Object implements InboundMessageMapper<TcpConnection>, OutboundMessageMapper<Object>, BeanFactoryAware
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.Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
TcpMessageMapper() |
Modifier and Type | Method and Description |
---|---|
protected void |
addCustomHeaders(TcpConnection connection,
AbstractIntegrationMessageBuilder<?> messageBuilder) |
protected void |
addStandardHeaders(TcpConnection connection,
AbstractIntegrationMessageBuilder<?> messageBuilder) |
Object |
fromMessage(Message<?> message) |
protected MessageBuilderFactory |
getMessageBuilderFactory() |
void |
setApplySequence(boolean applySequence) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setCharset(String charset) |
void |
setStringToBytes(boolean stringToBytes)
Sets whether outbound String payloads are to be converted
to byte[].
|
protected Map<String,?> |
supplyCustomHeaders(TcpConnection connection)
Override to provide additional headers.
|
Message<?> |
toMessage(TcpConnection connection) |
public void setCharset(String charset)
charset
- the charset to setpublic void setStringToBytes(boolean stringToBytes)
stringToBytes
- The stringToBytes to set.public void setApplySequence(boolean applySequence)
applySequence
- The applySequence to set.public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
protected MessageBuilderFactory getMessageBuilderFactory()
public Message<?> toMessage(TcpConnection connection) throws Exception
toMessage
in interface InboundMessageMapper<TcpConnection>
Exception
protected final void addStandardHeaders(TcpConnection connection, AbstractIntegrationMessageBuilder<?> messageBuilder)
protected final void addCustomHeaders(TcpConnection connection, AbstractIntegrationMessageBuilder<?> messageBuilder)
protected Map<String,?> supplyCustomHeaders(TcpConnection connection)
connection
- the connection.<String, ?>
headers to be added to the message.public Object fromMessage(Message<?> message) throws Exception
fromMessage
in interface OutboundMessageMapper<Object>
Exception