Class AbstractJaxbElementProvider
- java.lang.Object
-
- org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider<T>
-
- org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider<jakarta.xml.bind.JAXBElement<?>>
-
- org.glassfish.jersey.jaxb.internal.AbstractJaxbElementProvider
-
- All Implemented Interfaces:
MessageBodyReader<jakarta.xml.bind.JAXBElement<?>>,MessageBodyWriter<jakarta.xml.bind.JAXBElement<?>>
- Direct Known Subclasses:
XmlJaxbElementProvider
public abstract class AbstractJaxbElementProvider extends AbstractJaxbProvider<jakarta.xml.bind.JAXBElement<?>>
An abstract provider forJAXBElement. Implementing classes may extend this class to provide specific marshalling and unmarshalling behaviour. When unmarshalling aUnmarshalExceptionwill 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 aJAXBExceptionwill 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 AbstractJaxbElementProvider(Providers providers)Inheritance constructor.AbstractJaxbElementProvider(Providers providers, MediaType resolverMediaType)Inheritance constructor.
-
Method Summary
All Methods Instance Methods Abstract 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 abstract jakarta.xml.bind.JAXBElement<?>readFrom(Class<?> type, MediaType mediaType, jakarta.xml.bind.Unmarshaller unmarshaller, InputStream entityStream)Read JAXB element from an entity stream.jakarta.xml.bind.JAXBElement<?>readFrom(Class<jakarta.xml.bind.JAXBElement<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream inputStream)protected abstract voidwriteTo(jakarta.xml.bind.JAXBElement<?> element, MediaType mediaType, Charset charset, jakarta.xml.bind.Marshaller marshaller, OutputStream entityStream)Write JAXB element to an entity stream.voidwriteTo(jakarta.xml.bind.JAXBElement<?> 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
-
AbstractJaxbElementProvider
public AbstractJaxbElementProvider(Providers providers)
Inheritance constructor.- Parameters:
providers- JAX-RS providers.
-
-
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 jakarta.xml.bind.JAXBElement<?> readFrom(Class<jakarta.xml.bind.JAXBElement<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream inputStream) throws IOException
- Throws:
IOException
-
readFrom
protected abstract jakarta.xml.bind.JAXBElement<?> readFrom(Class<?> type, MediaType mediaType, jakarta.xml.bind.Unmarshaller unmarshaller, InputStream entityStream) throws jakarta.xml.bind.JAXBException
Read JAXB element from an entity stream.- Parameters:
type- the type that is to be read from the entity stream.mediaType- the media type of the HTTP entity.unmarshaller- JAXB unmarshaller to be used.entityStream- theInputStreamof the HTTP entity. The caller is responsible for ensuring that the input stream ends when the entity has been consumed. The implementation should not close the input stream.- Returns:
- JAXB element representing the entity.
- Throws:
jakarta.xml.bind.JAXBException- in case entity unmarshalling fails.
-
writeTo
public final void writeTo(jakarta.xml.bind.JAXBElement<?> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException- Throws:
IOException
-
writeTo
protected abstract void writeTo(jakarta.xml.bind.JAXBElement<?> element, MediaType mediaType, Charset charset, jakarta.xml.bind.Marshaller marshaller, OutputStream entityStream) throws jakarta.xml.bind.JAXBExceptionWrite JAXB element to an entity stream.- Parameters:
element- JAXB element to be written to an entity stream.mediaType- the media type of the HTTP entity.charset- character set to be used.marshaller- JAXB unmarshaller to be used.entityStream- theInputStreamof the HTTP entity. The caller is responsible for ensuring that the input stream ends when the entity has been consumed. The implementation should not close the input stream.- Throws:
jakarta.xml.bind.JAXBException- in case entity marshalling fails.
-
-