Class SimpleMessageConverter
- java.lang.Object
-
- org.springframework.amqp.support.converter.AbstractMessageConverter
-
- org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter
-
- org.springframework.amqp.support.converter.SimpleMessageConverter
-
- All Implemented Interfaces:
MessageConverter
,Aware
,BeanClassLoaderAware
public class SimpleMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware
Implementation ofMessageConverter
that can work with Strings, Serializable instances, or byte arrays. TheAbstractMessageConverter.toMessage(Object, MessageProperties)
method simply checks the type of the provided instance while thefromMessage(Message)
method relies upon thecontent-type
of the provided Message.- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CHARSET
-
Constructor Summary
Constructors Constructor Description SimpleMessageConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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)
Deprecated.due to deprecation ofCodebaseAwareObjectInputStream
.void
setDefaultCharset(String defaultCharset)
Specify the default charset to use when converting to or from text-based Message body content.-
Methods inherited from class org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter
addAllowedListPatterns, checkAllowedList, setAllowedListPatterns
-
Methods inherited from class org.springframework.amqp.support.converter.AbstractMessageConverter
createMessage, isCreateMessageIds, setCreateMessageIds, toMessage, toMessage
-
-
-
-
Field Detail
-
DEFAULT_CHARSET
public static final String DEFAULT_CHARSET
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBeanClassLoader
public void setBeanClassLoader(ClassLoader beanClassLoader)
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
setCodebaseUrl
@Deprecated public void setCodebaseUrl(String codebaseUrl)
Deprecated.due to deprecation ofCodebaseAwareObjectInputStream
.Set the codebase URL to download classes from if not found locally. Can consist of multiple URLs, separated by spaces.Follows RMI's codebase conventions for dynamic class download.
- Parameters:
codebaseUrl
- The codebase URL.- See Also:
CodebaseAwareObjectInputStream
,RMIClassLoader
-
setDefaultCharset
public void setDefaultCharset(String defaultCharset)
Specify the default charset to use when converting to or from text-based Message body content. If not specified, the charset will be "UTF-8".- Parameters:
defaultCharset
- The default charset.
-
fromMessage
public Object fromMessage(Message message) throws MessageConversionException
Converts from a AMQP Message to an Object.- Specified by:
fromMessage
in interfaceMessageConverter
- Parameters:
message
- the message to convert- Returns:
- the converted Java object
- Throws:
MessageConversionException
- in case of conversion failure
-
createMessage
protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException
Creates an AMQP Message from the provided Object.- Specified by:
createMessage
in classAbstractMessageConverter
- Parameters:
object
- the payload.messageProperties
- the message properties (headers).- Returns:
- a message.
- Throws:
MessageConversionException
-
createObjectInputStream
protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException
Create an ObjectInputStream for the given InputStream and codebase. The default implementation creates a CodebaseAwareObjectInputStream.- Parameters:
is
- the InputStream to read fromcodebaseUrl
- the codebase URL to load classes from if not found locally (can benull
)- Returns:
- the new ObjectInputStream instance to use
- Throws:
IOException
- if creation of the ObjectInputStream failed- See Also:
CodebaseAwareObjectInputStream
-
-