public class MarshallingPayloadMethodProcessor extends AbstractPayloadMethodProcessor
MethodArgumentResolver
and MethodReturnValueHandler
that uses Marshaller
and Unmarshaller
to support marshalled objects.logger
Constructor and Description |
---|
MarshallingPayloadMethodProcessor()
Creates a new
MarshallingPayloadMethodProcessor . |
MarshallingPayloadMethodProcessor(org.springframework.oxm.Marshaller marshaller)
Creates a new
MarshallingPayloadMethodProcessor with the given marshaller. |
MarshallingPayloadMethodProcessor(org.springframework.oxm.Marshaller marshaller,
org.springframework.oxm.Unmarshaller unmarshaller)
Creates a new
MarshallingPayloadMethodProcessor with the given marshaller and unmarshaller. |
Modifier and Type | Method and Description |
---|---|
org.springframework.oxm.Marshaller |
getMarshaller()
Returns the marshaller used for transforming objects into XML.
|
org.springframework.oxm.Unmarshaller |
getUnmarshaller()
Returns the unmarshaller used for transforming XML into objects.
|
void |
handleReturnValue(MessageContext messageContext,
org.springframework.core.MethodParameter returnType,
Object returnValue)
Handles the given return value.
|
Object |
resolveArgument(MessageContext messageContext,
org.springframework.core.MethodParameter parameter)
Resolves the given parameter into a method argument.
|
void |
setMarshaller(org.springframework.oxm.Marshaller marshaller)
Sets the marshaller used for transforming objects into XML.
|
void |
setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
Sets the unmarshaller used for transforming XML into objects.
|
protected boolean |
supportsRequestPayloadParameter(org.springframework.core.MethodParameter parameter)
Indicates whether the given method parameter, annotated with
RequestPayload ,
is supported by this resolver. |
protected boolean |
supportsResponsePayloadReturnType(org.springframework.core.MethodParameter returnType)
Indicates whether the given method return type, annotated with
ResponsePayload , is supported. |
convertToByteArrayInputStream, supportsParameter, supportsReturnType
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
public MarshallingPayloadMethodProcessor()
MarshallingPayloadMethodProcessor
. The Marshaller
and Unmarshaller
must be
injected using properties.public MarshallingPayloadMethodProcessor(org.springframework.oxm.Marshaller marshaller)
MarshallingPayloadMethodProcessor
with the given marshaller. If the given Marshaller
also implements the Unmarshaller
interface, it is used for both marshalling and
unmarshalling. Otherwise, an exception is thrown.
Note that all Marshaller
implementations in Spring also implement the Unmarshaller
interface, so
that you can safely use this constructor.
marshaller
- object used as marshaller and unmarshallerIllegalArgumentException
- when marshaller
does not implement the Unmarshaller
interfacepublic MarshallingPayloadMethodProcessor(org.springframework.oxm.Marshaller marshaller, org.springframework.oxm.Unmarshaller unmarshaller)
MarshallingPayloadMethodProcessor
with the given marshaller and unmarshaller.marshaller
- the marshaller to useunmarshaller
- the unmarshaller to usepublic org.springframework.oxm.Marshaller getMarshaller()
public void setMarshaller(org.springframework.oxm.Marshaller marshaller)
public org.springframework.oxm.Unmarshaller getUnmarshaller()
public void setUnmarshaller(org.springframework.oxm.Unmarshaller unmarshaller)
protected boolean supportsRequestPayloadParameter(org.springframework.core.MethodParameter parameter)
AbstractPayloadMethodProcessor
RequestPayload
,
is supported by this resolver.supportsRequestPayloadParameter
in class AbstractPayloadMethodProcessor
parameter
- the method parameter to checktrue
if this resolver supports the supplied parameter; false
otherwisepublic Object resolveArgument(MessageContext messageContext, org.springframework.core.MethodParameter parameter) throws Exception
MethodArgumentResolver
messageContext
- the current message contextparameter
- the parameter to resolve to an argument. This parameter must have previously been passed to
the MethodArgumentResolver.supportsParameter(MethodParameter)
method of this interface, which must
have returned true
.null
.Exception
- in case of errorsprotected boolean supportsResponsePayloadReturnType(org.springframework.core.MethodParameter returnType)
AbstractPayloadMethodProcessor
ResponsePayload
, is supported.supportsResponsePayloadReturnType
in class AbstractPayloadMethodProcessor
returnType
- the method parameter to checktrue
if this resolver supports the supplied return type; false
otherwisepublic void handleReturnValue(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) throws Exception
MethodReturnValueHandler
messageContext
- the current message contextreturnType
- the return type to handle. This type must have previously been passed to the MethodReturnValueHandler.supportsReturnType(MethodParameter)
method of this interface, which must have returned
true
.returnValue
- the return value to handleException
- in case of errorsCopyright © 2020 Pivotal Software. All rights reserved.