public class SimpleMessageConverter extends WhiteListDeserializingMessageConverter implements org.springframework.beans.factory.BeanClassLoaderAware
MessageConverter
that can work with Strings, Serializable
instances, or byte arrays. The AbstractMessageConverter.toMessage(Object, MessageProperties)
method
simply checks the type of the provided instance while the fromMessage(Message)
method relies upon the content-type
of the
provided Message.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CHARSET |
Constructor and Description |
---|
SimpleMessageConverter() |
Modifier and Type | Method and Description |
---|---|
protected Message |
createMessage(Object object,
MessageProperties messageProperties)
Creates an AMQP Message from the provided Object.
|
protected ObjectInputStream |
createObjectInputStream(InputStream is,
String codebaseUrl)
Create an ObjectInputStream for the given InputStream and codebase.
|
Object |
fromMessage(Message message)
Converts from a AMQP Message to an Object.
|
void |
setBeanClassLoader(ClassLoader beanClassLoader) |
void |
setCodebaseUrl(String codebaseUrl)
Set the codebase URL to download classes from if not found locally.
|
void |
setDefaultCharset(String defaultCharset)
Specify the default charset to use when converting to or from text-based
Message body content.
|
addWhiteListPatterns, checkWhiteList, setWhiteListPatterns
isCreateMessageIds, setCreateMessageIds, toMessage
public static final String DEFAULT_CHARSET
public void setBeanClassLoader(ClassLoader beanClassLoader)
setBeanClassLoader
in interface org.springframework.beans.factory.BeanClassLoaderAware
public void setCodebaseUrl(String codebaseUrl)
Follows RMI's codebase conventions for dynamic class download.
codebaseUrl
- The codebase URL.CodebaseAwareObjectInputStream
,
RMIClassLoader
public void setDefaultCharset(String defaultCharset)
defaultCharset
- The default charset.public Object fromMessage(Message message) throws MessageConversionException
fromMessage
in interface MessageConverter
fromMessage
in class AbstractMessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failureprotected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException
createMessage
in class AbstractMessageConverter
object
- the payloadmessageProperties
- the message properties (headers)MessageConversionException
protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException
is
- the InputStream to read fromcodebaseUrl
- the codebase URL to load classes from if not found locally (can be null
)IOException
- if creation of the ObjectInputStream failedCodebaseAwareObjectInputStream