Class AbstractRootElementJaxbProvider
- java.lang.Object
-
- org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider<T>
-
- org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider<Object>
-
- org.glassfish.jersey.jaxb.internal.AbstractRootElementJaxbProvider
-
- All Implemented Interfaces:
MessageBodyReader<Object>,MessageBodyWriter<Object>
- Direct Known Subclasses:
XmlRootElementJaxbProvider
public abstract class AbstractRootElementJaxbProvider extends AbstractJaxbProvider<Object>
An abstract provider for JAXB types that are annotated withXmlRootElementorXmlType.Implementing classes may extend this class to provide specific marshalling and unmarshalling behaviour.
When unmarshalling a
UnmarshalExceptionwill result in aWebApplicationExceptionbeing thrown with a status of 400 (Client error), and aJAXBExceptionwill result in aWebApplicationExceptionbeing thrown with a status of 500 (Internal Server error).When marshalling a
JAXBExceptionwill result in aWebApplicationExceptionbeing thrown with a status of 500 (Internal Server error).- Author:
- Paul Sandoz, Marek Potociar
-
-
Field Summary
-
Fields inherited from class org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider
UTF8
-
-
Constructor Summary
Constructors Constructor Description AbstractRootElementJaxbProvider(Providers providers, Configuration config)Inheritance constructor.AbstractRootElementJaxbProvider(Providers providers, MediaType resolverMediaType, Configuration config)Inheritance constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)booleanisWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)protected ObjectreadFrom(Class<Object> type, MediaType mediaType, jakarta.xml.bind.Unmarshaller u, InputStream entityStream)Unmarshal a JAXB type.ObjectreadFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream inputStream)protected voidwriteTo(Object t, MediaType mediaType, Charset c, jakarta.xml.bind.Marshaller m, OutputStream entityStream)Marshal an instance of a JAXB type.voidwriteTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)-
Methods inherited from class org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider
getMarshaller, getSAXSource, getStoredJaxbContext, getUnmarshaller, isFormattedOutput, isSupported, isXmlRootElementProcessing, setConfiguration, setHeader
-
Methods inherited from class org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider
getCharset, getSize, readFromAsString, writeTo, writeTo, writeToAsString
-
-
-
-
Constructor Detail
-
AbstractRootElementJaxbProvider
public AbstractRootElementJaxbProvider(Providers providers, Configuration config)
Inheritance constructor.- Parameters:
providers- JAX-RS providers.
-
AbstractRootElementJaxbProvider
public AbstractRootElementJaxbProvider(Providers providers, MediaType resolverMediaType, Configuration config)
Inheritance constructor.- Parameters:
providers- JAX-RS providers.resolverMediaType- JAXB component context resolver media type to be used.
-
-
Method Detail
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
-
readFrom
public final Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream inputStream) throws IOException
- Throws:
IOException
-
readFrom
protected Object readFrom(Class<Object> type, MediaType mediaType, jakarta.xml.bind.Unmarshaller u, InputStream entityStream) throws jakarta.xml.bind.JAXBException
Unmarshal a JAXB type.Implementing classes may override this method.
- Parameters:
type- the JAXB typemediaType- the media typeu- the unmarshaller to use for unmarshalling.entityStream- the input stream to unmarshal from.- Returns:
- an instance of the JAXB type.
- Throws:
jakarta.xml.bind.JAXBException- in case the JAXB unmarshalling fails.
-
writeTo
public final void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException
- Throws:
IOException
-
writeTo
protected void writeTo(Object t, MediaType mediaType, Charset c, jakarta.xml.bind.Marshaller m, OutputStream entityStream) throws jakarta.xml.bind.JAXBException
Marshal an instance of a JAXB type.Implementing classes may override this method.
- Parameters:
t- the instance of the JAXB type.mediaType- the media type.c- the character set to serialize characters to.m- the marshaller to marshaller the instance of the JAXB type.entityStream- the output stream to marshal to.- Throws:
jakarta.xml.bind.JAXBException- in case the JAXB marshalling fails.
-
-