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 |
setAddContentTypeHeader(boolean addContentTypeHeader)
Set to true to add a content type header; default false.
|
void |
setApplySequence(boolean applySequence) |
void |
setBeanFactory(BeanFactory beanFactory) |
void |
setCharset(String charset)
Set the charset to use when converting outbound String messages to
byte[]. |
void |
setContentType(String contentType)
Set the content type header value to add to inbound messages when
addContentTypeHeader is true. |
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)
byte[].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 setContentType(String contentType)
addContentTypeHeader is true.
Default application/octet-stream;charset=UTF-8. This default is not
modified by setCharset(String).contentType - the content type header value to set.setAddContentTypeHeader(boolean),
setCharset(String)public void setAddContentTypeHeader(boolean addContentTypeHeader)
addContentTypeHeader - true to add a content type header.setContentType(String)public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory in interface BeanFactoryAwareBeansExceptionprotected MessageBuilderFactory getMessageBuilderFactory()
public Message<?> toMessage(TcpConnection connection) throws Exception
toMessage in interface InboundMessageMapper<TcpConnection>Exceptionprotected 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