Class AbstractJaxb2HttpMessageConverter<T>
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter<T>
- Type Parameters:
- T- the converted object type
- All Implemented Interfaces:
- HttpMessageConverter<T>
- Direct Known Subclasses:
- Jaxb2CollectionHttpMessageConverter,- Jaxb2RootElementHttpMessageConverter
public abstract class AbstractJaxb2HttpMessageConverter<T>
extends AbstractXmlHttpMessageConverter<T>
Abstract base class for 
HttpMessageConverters
 that use JAXB2. Creates JAXBContext object lazily.- Since:
- 3.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
- 
Field SummaryFields inherited from class org.springframework.http.converter.AbstractHttpMessageConverterlogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final jakarta.xml.bind.MarshallercreateMarshaller(Class<?> clazz) Create a newMarshallerfor the given class.protected final jakarta.xml.bind.UnmarshallercreateUnmarshaller(Class<?> clazz) Create a newUnmarshallerfor the given class.protected voidcustomizeMarshaller(jakarta.xml.bind.Marshaller marshaller) Customize theMarshallercreated by this message converter before using it to write the object to the output.protected voidcustomizeUnmarshaller(jakarta.xml.bind.Unmarshaller unmarshaller) Customize theUnmarshallercreated by this message converter before using it to read the object from the input.detectCharset(HttpHeaders httpHeaders) Detect the charset from the givenHttpHeaders.getContentType().protected final jakarta.xml.bind.JAXBContextgetJaxbContext(Class<?> clazz) Return aJAXBContextfor the given class.Methods inherited from class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverterreadFromSource, readInternal, transform, writeInternal, writeToResultMethods inherited from class org.springframework.http.converter.AbstractHttpMessageConverteraddDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supports, supportsRepeatableWrites, writeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.converter.HttpMessageConvertergetSupportedMediaTypes
- 
Constructor Details- 
AbstractJaxb2HttpMessageConverterpublic AbstractJaxb2HttpMessageConverter()
 
- 
- 
Method Details- 
createMarshallerCreate a newMarshallerfor the given class.- Parameters:
- clazz- the class to create the marshaller for
- Returns:
- the Marshaller
- Throws:
- HttpMessageConversionException- in case of JAXB errors
 
- 
customizeMarshallerprotected void customizeMarshaller(jakarta.xml.bind.Marshaller marshaller) Customize theMarshallercreated by this message converter before using it to write the object to the output.- Parameters:
- marshaller- the marshaller to customize
- Since:
- 4.0.3
- See Also:
 
- 
createUnmarshallerCreate a newUnmarshallerfor the given class.- Parameters:
- clazz- the class to create the unmarshaller for
- Returns:
- the Unmarshaller
- Throws:
- HttpMessageConversionException- in case of JAXB errors
 
- 
customizeUnmarshallerprotected void customizeUnmarshaller(jakarta.xml.bind.Unmarshaller unmarshaller) Customize theUnmarshallercreated by this message converter before using it to read the object from the input.- Parameters:
- unmarshaller- the unmarshaller to customize
- Since:
- 4.0.3
- See Also:
 
- 
getJaxbContextReturn aJAXBContextfor the given class.- Parameters:
- clazz- the class to return the context for
- Returns:
- the JAXBContext
- Throws:
- HttpMessageConversionException- in case of JAXB errors
 
- 
detectCharsetDetect the charset from the givenHttpHeaders.getContentType().- Parameters:
- httpHeaders- the current HTTP headers
- Returns:
- the charset defined in the content type header, or nullif not found
- Since:
- 6.2.8
 
 
-