public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloadMethodProcessor
MethodArgumentResolver
and MethodReturnValueHandler
implementations that use JAXB2. Creates JAXBContext
object lazily, and offers
marshalling and
unmarshalling
methods.logger
Constructor and Description |
---|
AbstractJaxb2PayloadMethodProcessor() |
Modifier and Type | Method and Description |
---|---|
protected Marshaller |
createMarshaller(JAXBContext jaxbContext)
Creates a new
Marshaller to be used for marshalling objects to XML. |
protected Unmarshaller |
createUnmarshaller(JAXBContext jaxbContext)
Creates a new
Unmarshaller to be used for unmarshalling XML to objects. |
void |
handleReturnValue(MessageContext messageContext,
org.springframework.core.MethodParameter returnType,
Object returnValue)
Handles the given return value.
|
protected abstract void |
handleReturnValueInternal(MessageContext messageContext,
org.springframework.core.MethodParameter returnType,
Object returnValue) |
protected void |
marshalToResponsePayload(MessageContext messageContext,
Class<?> clazz,
Object jaxbElement)
Marshals the given
jaxbElement to the response payload of the given message context. |
protected <T> JAXBElement<T> |
unmarshalElementFromRequestPayload(MessageContext messageContext,
Class<T> clazz)
Unmarshals the request payload of the given message context as
JAXBElement . |
protected Object |
unmarshalFromRequestPayload(MessageContext messageContext,
Class<?> clazz)
Unmarshals the request payload of the given message context.
|
convertToByteArrayInputStream, supportsParameter, supportsRequestPayloadParameter, supportsResponsePayloadReturnType, supportsReturnType
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resolveArgument
public final 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 errorsprotected abstract void handleReturnValueInternal(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) throws Exception
Exception
protected final void marshalToResponsePayload(MessageContext messageContext, Class<?> clazz, Object jaxbElement) throws JAXBException
jaxbElement
to the response payload of the given message context.messageContext
- the message context to marshal toclazz
- the clazz to create a marshaller forjaxbElement
- the object to be marshalledJAXBException
- in case of JAXB2 errorsprotected final Object unmarshalFromRequestPayload(MessageContext messageContext, Class<?> clazz) throws JAXBException
messageContext
- the message context to unmarshal fromclazz
- the class to unmarshalnull
if the request has no payloadJAXBException
- in case of JAXB2 errorsprotected final <T> JAXBElement<T> unmarshalElementFromRequestPayload(MessageContext messageContext, Class<T> clazz) throws JAXBException
JAXBElement
.messageContext
- the message context to unmarshal fromclazz
- the class to unmarshalnull
if the request has no payloadJAXBException
- in case of JAXB2 errorsprotected Marshaller createMarshaller(JAXBContext jaxbContext) throws JAXBException
Marshaller
to be used for marshalling objects to XML. Defaults to
JAXBContext.createMarshaller()
, but can be overridden in subclasses for further
customization.jaxbContext
- the JAXB context to create a marshaller forJAXBException
- in case of JAXB errorsprotected Unmarshaller createUnmarshaller(JAXBContext jaxbContext) throws JAXBException
Unmarshaller
to be used for unmarshalling XML to objects. Defaults to
JAXBContext.createUnmarshaller()
, but can be overridden in subclasses for further
customization.jaxbContext
- the JAXB context to create a unmarshaller forJAXBException
- in case of JAXB errorsCopyright © 2018 Pivotal Software. All rights reserved.