类 MarshallingMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.AbstractMessageConverter
- org.springframework.messaging.converter.MarshallingMessageConverter
- 所有已实现的接口:
MessageConverter
,SmartMessageConverter
public class MarshallingMessageConverter extends AbstractMessageConverter
Implementation ofMessageConverter
that can read and write XML using Spring'sMarshaller
andUnmarshaller
abstractions.This converter requires a
Marshaller
andUnmarshaller
before it can be used. These can be injected by the constructor or bean properties.- 从以下版本开始:
- 4.2
- 作者:
- Arjen Poutsma
- 另请参阅:
Marshaller
,Unmarshaller
字段概要
从类继承的字段 org.springframework.messaging.converter.AbstractMessageConverter
logger
构造器概要
构造器 构造器 说明 MarshallingMessageConverter()
Default construct allowing forsetMarshaller(Marshaller)
and/orsetUnmarshaller(Unmarshaller)
to be invoked separately.MarshallingMessageConverter(Marshaller marshaller)
Constructor withMarshaller
.MarshallingMessageConverter(MimeType... supportedMimeTypes)
Constructor with a given list of MIME types to support.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected boolean
canConvertFrom(Message<?> message, Class<?> targetClass)
protected boolean
canConvertTo(Object payload, MessageHeaders headers)
protected Object
convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint)
Convert the message payload from serialized form to an Object.protected Object
convertToInternal(Object payload, MessageHeaders headers, Object conversionHint)
Convert the payload object to serialized form.Marshaller
getMarshaller()
Return the configured Marshaller.Unmarshaller
getUnmarshaller()
Return the configured unmarshaller.void
setMarshaller(Marshaller marshaller)
Set theMarshaller
to be used by this message converter.void
setUnmarshaller(Unmarshaller unmarshaller)
Set theUnmarshaller
to be used by this message converter.protected boolean
supports(Class<?> clazz)
Whether the given class is supported by this converter.从类继承的方法 org.springframework.messaging.converter.AbstractMessageConverter
convertFromInternal, convertToInternal, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
构造器详细资料
MarshallingMessageConverter
public MarshallingMessageConverter()
Default construct allowing forsetMarshaller(Marshaller)
and/orsetUnmarshaller(Unmarshaller)
to be invoked separately.
MarshallingMessageConverter
public MarshallingMessageConverter(MimeType... supportedMimeTypes)
Constructor with a given list of MIME types to support.- 参数:
supportedMimeTypes
- the MIME types
MarshallingMessageConverter
public MarshallingMessageConverter(Marshaller marshaller)
Constructor withMarshaller
. If the givenMarshaller
also implementsUnmarshaller
, it is also used for unmarshalling.Note that all
Marshaller
implementations in Spring also implementUnmarshaller
so that you can safely use this constructor.- 参数:
marshaller
- object used as marshaller and unmarshaller
方法详细资料
setMarshaller
public void setMarshaller(Marshaller marshaller)
Set theMarshaller
to be used by this message converter.
getMarshaller
public Marshaller getMarshaller()
Return the configured Marshaller.
setUnmarshaller
public void setUnmarshaller(Unmarshaller unmarshaller)
Set theUnmarshaller
to be used by this message converter.
getUnmarshaller
public Unmarshaller getUnmarshaller()
Return the configured unmarshaller.
canConvertFrom
protected boolean canConvertFrom(Message<?> message, Class<?> targetClass)
canConvertTo
protected boolean canConvertTo(Object payload, MessageHeaders headers)
supports
protected boolean supports(Class<?> clazz)
从类复制的说明:AbstractMessageConverter
Whether the given class is supported by this converter.- 指定者:
supports
在类中AbstractMessageConverter
- 参数:
clazz
- the class to test for support- 返回:
true
if supported;false
otherwise
convertFromInternal
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint)
从类复制的说明:AbstractMessageConverter
Convert the message payload from serialized form to an Object.- 覆盖:
convertFromInternal
在类中AbstractMessageConverter
- 参数:
message
- the input messagetargetClass
- the target class for the conversionconversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- 返回:
- the result of the conversion, or
null
if the converter cannot perform the conversion
convertToInternal
protected Object convertToInternal(Object payload, MessageHeaders headers, Object conversionHint)
从类复制的说明:AbstractMessageConverter
Convert the payload object to serialized form.- 覆盖:
convertToInternal
在类中AbstractMessageConverter
- 参数:
payload
- the Object to convertheaders
- optional headers for the message (may benull
)conversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- 返回:
- the resulting payload for the message, or
null
if the converter cannot perform the conversion