Class AbstractJaxb2PayloadMethodProcessor
java.lang.Object
org.springframework.xml.transform.TransformerObjectSupport
org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessor
org.springframework.ws.server.endpoint.adapter.method.jaxb.AbstractJaxb2PayloadMethodProcessor
- All Implemented Interfaces:
MethodArgumentResolver,MethodReturnValueHandler
- Direct Known Subclasses:
JaxbElementPayloadMethodProcessor,XmlRootElementPayloadMethodProcessor
Abstract base class for
MethodArgumentResolver and MethodReturnValueHandler implementations that use JAXB2. Creates JAXBContext object lazily, and offers
marshalling and
unmarshalling
methods.- Since:
- 2.0
- Author:
- Arjen Poutsma
-
Field Summary
Fields inherited from class org.springframework.xml.transform.TransformerObjectSupport
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.xml.bind.MarshallercreateMarshaller(jakarta.xml.bind.JAXBContext jaxbContext) Creates a newMarshallerto be used for marshalling objects to XML.protected jakarta.xml.bind.UnmarshallercreateUnmarshaller(jakarta.xml.bind.JAXBContext jaxbContext) Creates a newUnmarshallerto be used for unmarshalling XML to objects.final voidhandleReturnValue(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) Handles the given return value.protected abstract voidhandleReturnValueInternal(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) protected final voidmarshalToResponsePayload(MessageContext messageContext, Class<?> clazz, Object jaxbElement) Marshals the givenjaxbElementto the response payload of the given message context.protected final <T> jakarta.xml.bind.JAXBElement<T>unmarshalElementFromRequestPayload(MessageContext messageContext, Class<T> clazz) Unmarshals the request payload of the given message context asJAXBElement.protected final ObjectunmarshalFromRequestPayload(MessageContext messageContext, Class<?> clazz) Unmarshals the request payload of the given message context.Methods inherited from class org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessor
convertToByteArrayInputStream, supportsParameter, supportsRequestPayloadParameter, supportsResponsePayloadReturnType, supportsReturnTypeMethods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transformMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
resolveArgument
-
Constructor Details
-
AbstractJaxb2PayloadMethodProcessor
public AbstractJaxb2PayloadMethodProcessor()
-
-
Method Details
-
handleReturnValue
public final void handleReturnValue(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) throws Exception Description copied from interface:MethodReturnValueHandlerHandles the given return value.- Parameters:
messageContext- the current message contextreturnType- the return type to handle. This type must have previously been passed to theMethodReturnValueHandler.supportsReturnType(MethodParameter)method of this interface, which must have returnedtrue.returnValue- the return value to handle- Throws:
Exception- in case of errors
-
handleReturnValueInternal
protected abstract void handleReturnValueInternal(MessageContext messageContext, org.springframework.core.MethodParameter returnType, Object returnValue) throws Exception - Throws:
Exception
-
marshalToResponsePayload
protected final void marshalToResponsePayload(MessageContext messageContext, Class<?> clazz, Object jaxbElement) throws jakarta.xml.bind.JAXBException Marshals the givenjaxbElementto the response payload of the given message context.- Parameters:
messageContext- the message context to marshal toclazz- the clazz to create a marshaller forjaxbElement- the object to be marshalled- Throws:
jakarta.xml.bind.JAXBException- in case of JAXB2 errors
-
unmarshalFromRequestPayload
protected final Object unmarshalFromRequestPayload(MessageContext messageContext, Class<?> clazz) throws jakarta.xml.bind.JAXBException Unmarshals the request payload of the given message context.- Parameters:
messageContext- the message context to unmarshal fromclazz- the class to unmarshal- Returns:
- the unmarshalled object, or
nullif the request has no payload - Throws:
jakarta.xml.bind.JAXBException- in case of JAXB2 errors
-
unmarshalElementFromRequestPayload
protected final <T> jakarta.xml.bind.JAXBElement<T> unmarshalElementFromRequestPayload(MessageContext messageContext, Class<T> clazz) throws jakarta.xml.bind.JAXBException Unmarshals the request payload of the given message context asJAXBElement.- Parameters:
messageContext- the message context to unmarshal fromclazz- the class to unmarshal- Returns:
- the unmarshalled element, or
nullif the request has no payload - Throws:
jakarta.xml.bind.JAXBException- in case of JAXB2 errors
-
createMarshaller
protected jakarta.xml.bind.Marshaller createMarshaller(jakarta.xml.bind.JAXBContext jaxbContext) throws jakarta.xml.bind.JAXBException Creates a newMarshallerto be used for marshalling objects to XML. Defaults toJAXBContext.createMarshaller(), but can be overridden in subclasses for further customization.- Parameters:
jaxbContext- the JAXB context to create a marshaller for- Returns:
- the marshaller
- Throws:
jakarta.xml.bind.JAXBException- in case of JAXB errors
-
createUnmarshaller
protected jakarta.xml.bind.Unmarshaller createUnmarshaller(jakarta.xml.bind.JAXBContext jaxbContext) throws jakarta.xml.bind.JAXBException Creates a newUnmarshallerto be used for unmarshalling XML to objects. Defaults toJAXBContext.createUnmarshaller(), but can be overridden in subclasses for further customization.- Parameters:
jaxbContext- the JAXB context to create a unmarshaller for- Returns:
- the unmarshaller
- Throws:
jakarta.xml.bind.JAXBException- in case of JAXB errors
-