Top Description Fields Constructors Methods
org.springframework.http.converter.xml

public abstract Class AbstractJaxb2HttpMessageConverter<T>

extends AbstractXmlHttpMessageConverter<T>
Class Inheritance
Known Direct Subclasses
org.springframework.http.converter.xml.Jaxb2CollectionHttpMessageConverter, org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter
Type Parameters
<T>
the converted object type
Imports
java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, jakarta.xml.bind.JAXBContext, .JAXBException, .Marshaller, .Unmarshaller, org.springframework.http.converter.HttpMessageConversionException

Abstract base class for HttpMessageConverters that use JAXB2. Creates JAXBContext object lazily.
Authors
Arjen Poutsma, Rossen Stoyanchev
Since
3.0

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<Class<?>, JAXBContext>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final Marshaller

Returns:

the Marshaller
createMarshaller
(Class<?>
the class to create the marshaller for
clazz
)

Create a new Marshaller for the given class.

protected final Unmarshaller

Returns:

the Unmarshaller
createUnmarshaller
(Class<?>
the class to create the unmarshaller for
clazz
)

Create a new Unmarshaller for the given class.

protected void
customizeMarshaller(Marshaller
the marshaller to customize
marshaller
)

Customize the Marshaller created by this message converter before using it to write the object to the output.

protected void
customizeUnmarshaller(Unmarshaller
the unmarshaller to customize
unmarshaller
)

Customize the Unmarshaller created by this message converter before using it to read the object from the input.

protected final JAXBContext

Returns:

the JAXBContext
getJaxbContext
(Class<?>
the class to return the context for
clazz
)

Return a JAXBContext for the given class.

Inherited from org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter:
readFromSourcereadInternaltransformwriteInternalwriteToResult

Field Detail

jaxbContextsback to summary
private final ConcurrentMap<Class<?>, JAXBContext> jaxbContexts

Constructor Detail

AbstractJaxb2HttpMessageConverterback to summary
public AbstractJaxb2HttpMessageConverter()

Method Detail

createMarshallerback to summary
protected final Marshaller createMarshaller(Class<?> clazz)

Create a new Marshaller for the given class.

Parameters
clazz:Class<?>

the class to create the marshaller for

Returns:Marshaller

the Marshaller

Exceptions
HttpMessageConversionException:
in case of JAXB errors
createUnmarshallerback to summary
protected final Unmarshaller createUnmarshaller(Class<?> clazz)

Create a new Unmarshaller for the given class.

Parameters
clazz:Class<?>

the class to create the unmarshaller for

Returns:Unmarshaller

the Unmarshaller

Exceptions
HttpMessageConversionException:
in case of JAXB errors
customizeMarshallerback to summary
protected void customizeMarshaller(Marshaller marshaller)

Customize the Marshaller created by this message converter before using it to write the object to the output.

Parameters
marshaller:Marshaller

the marshaller to customize

Since
4.0.3
See Also
createMarshaller(Class)
customizeUnmarshallerback to summary
protected void customizeUnmarshaller(Unmarshaller unmarshaller)

Customize the Unmarshaller created by this message converter before using it to read the object from the input.

Parameters
unmarshaller:Unmarshaller

the unmarshaller to customize

Since
4.0.3
See Also
createUnmarshaller(Class)
getJaxbContextback to summary
protected final JAXBContext getJaxbContext(Class<?> clazz)

Return a JAXBContext for the given class.

Parameters
clazz:Class<?>

the class to return the context for

Returns:JAXBContext

the JAXBContext

Exceptions
HttpMessageConversionException:
in case of JAXB errors