Class AbstractRootElementJaxbProvider
- java.lang.Object
-
- org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider<T>
-
- org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider<java.lang.Object>
-
- org.glassfish.jersey.jaxb.internal.AbstractRootElementJaxbProvider
-
- All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<java.lang.Object>,javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
- Direct Known Subclasses:
XmlRootElementJaxbProvider
public abstract class AbstractRootElementJaxbProvider extends AbstractJaxbProvider<java.lang.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).
-
-
Field Summary
-
Fields inherited from class org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider
UTF8
-
-
Constructor Summary
Constructors Constructor Description AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers providers)Inheritance constructor.AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers providers, javax.ws.rs.core.MediaType resolverMediaType)Inheritance constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisReadable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)booleanisWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)java.lang.ObjectreadFrom(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders, java.io.InputStream inputStream)protected java.lang.ObjectreadFrom(java.lang.Class<java.lang.Object> type, javax.ws.rs.core.MediaType mediaType, javax.xml.bind.Unmarshaller u, java.io.InputStream entityStream)Unmarshal a JAXB type.voidwriteTo(java.lang.Object t, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream)protected voidwriteTo(java.lang.Object t, javax.ws.rs.core.MediaType mediaType, java.nio.charset.Charset c, javax.xml.bind.Marshaller m, java.io.OutputStream entityStream)Marshal an instance of a JAXB type.-
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(javax.ws.rs.ext.Providers providers)
Inheritance constructor.- Parameters:
providers- JAX-RS providers.
-
AbstractRootElementJaxbProvider
public AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers providers, javax.ws.rs.core.MediaType resolverMediaType)Inheritance constructor.- Parameters:
providers- JAX-RS providers.resolverMediaType- JAXB component context resolver media type to be used.
-
-
Method Detail
-
isReadable
public boolean isReadable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
-
isWriteable
public boolean isWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
-
readFrom
public final java.lang.Object readFrom(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders, java.io.InputStream inputStream) throws java.io.IOException- Throws:
java.io.IOException
-
readFrom
protected java.lang.Object readFrom(java.lang.Class<java.lang.Object> type, javax.ws.rs.core.MediaType mediaType, javax.xml.bind.Unmarshaller u, java.io.InputStream entityStream) throws javax.xml.bind.JAXBExceptionUnmarshal 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:
javax.xml.bind.JAXBException- in case the JAXB unmarshalling fails.
-
writeTo
public final void writeTo(java.lang.Object t, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream) throws java.io.IOException- Throws:
java.io.IOException
-
writeTo
protected void writeTo(java.lang.Object t, javax.ws.rs.core.MediaType mediaType, java.nio.charset.Charset c, javax.xml.bind.Marshaller m, java.io.OutputStream entityStream) throws javax.xml.bind.JAXBExceptionMarshal 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:
javax.xml.bind.JAXBException- in case the JAXB marshalling fails.
-
-