Spring Web Services Framework

org.springframework.ws.server.endpoint.adapter.method.jaxb
Class AbstractJaxb2PayloadMethodProcessor

java.lang.Object
  extended by org.springframework.xml.transform.TransformerObjectSupport
      extended by org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessor
          extended by org.springframework.ws.server.endpoint.adapter.method.jaxb.AbstractJaxb2PayloadMethodProcessor
All Implemented Interfaces:
MethodArgumentResolver, MethodReturnValueHandler
Direct Known Subclasses:
JaxbElementPayloadMethodProcessor, XmlRootElementPayloadMethodProcessor

public abstract class AbstractJaxb2PayloadMethodProcessor
extends AbstractPayloadMethodProcessor

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
AbstractJaxb2PayloadMethodProcessor()
           
 
Method Summary
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.
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.
 
Methods inherited from class org.springframework.ws.server.endpoint.adapter.method.AbstractPayloadMethodProcessor
convertToByteArrayInputStream, supportsParameter, supportsRequestPayloadParameter, supportsResponsePayloadReturnType, supportsReturnType
 
Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver
resolveArgument
 
Methods inherited from interface org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler
handleReturnValue
 

Constructor Detail

AbstractJaxb2PayloadMethodProcessor

public AbstractJaxb2PayloadMethodProcessor()
Method Detail

marshalToResponsePayload

protected final void marshalToResponsePayload(MessageContext messageContext,
                                              Class<?> clazz,
                                              Object jaxbElement)
                                       throws JAXBException
Marshals the given jaxbElement to the response payload of the given message context.

Parameters:
messageContext - the message context to marshal to
clazz - the clazz to create a marshaller for
jaxbElement - the object to be marshalled
Throws:
JAXBException - in case of JAXB2 errors

unmarshalFromRequestPayload

protected final Object unmarshalFromRequestPayload(MessageContext messageContext,
                                                   Class<?> clazz)
                                            throws JAXBException
Unmarshals the request payload of the given message context.

Parameters:
messageContext - the message context to unmarshal from
clazz - the class to unmarshal
Returns:
the unmarshalled object, or null if the request has no payload
Throws:
JAXBException - in case of JAXB2 errors

unmarshalElementFromRequestPayload

protected final <T> JAXBElement<T> unmarshalElementFromRequestPayload(MessageContext messageContext,
                                                                      Class<T> clazz)
                                                           throws JAXBException
Unmarshals the request payload of the given message context as JAXBElement.

Parameters:
messageContext - the message context to unmarshal from
clazz - the class to unmarshal
Returns:
the unmarshalled element, or null if the request has no payload
Throws:
JAXBException - in case of JAXB2 errors

createMarshaller

protected Marshaller createMarshaller(JAXBContext jaxbContext)
                               throws JAXBException
Creates a new Marshaller to be used for marshalling objects to XML. Defaults to JAXBContext.createMarshaller(), but can be overridden in subclasses for further customization.

Parameters:
jaxbContext - the JAXB context to create a marshaller for
Returns:
the marshaller
Throws:
JAXBException - in case of JAXB errors

createUnmarshaller

protected Unmarshaller createUnmarshaller(JAXBContext jaxbContext)
                                   throws JAXBException
Creates a new Unmarshaller to be used for unmarshalling XML to objects. Defaults to JAXBContext.createUnmarshaller(), but can be overridden in subclasses for further customization.

Parameters:
jaxbContext - the JAXB context to create a unmarshaller for
Returns:
the unmarshaller
Throws:
JAXBException - in case of JAXB errors

Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.