org.glassfish.jersey.message.internal
Class AbstractRootElementJaxbProvider

java.lang.Object
  extended by org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider<T>
      extended by org.glassfish.jersey.message.internal.AbstractJaxbProvider<Object>
          extended by org.glassfish.jersey.message.internal.AbstractRootElementJaxbProvider
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>
Direct Known Subclasses:
XmlRootElementJaxbProvider

public abstract class AbstractRootElementJaxbProvider
extends AbstractJaxbProvider<Object>

An abstract provider for JAXB types that are annotated with XmlRootElement or XmlType.

Implementing classes may extend this class to provide specific marshalling and unmarshalling behaviour.

When unmarshalling a UnmarshalException will result in a WebApplicationException being thrown with a status of 400 (Client error), and a JAXBException will result in a WebApplicationException being thrown with a status of 500 (Internal Server error).

When marshalling a JAXBException will result in a WebApplicationException being thrown with a status of 500 (Internal Server error).

Author:
Paul Sandoz, Marek Potociar (marek.potociar at oracle.com)

Field Summary
 
Fields inherited from class org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider
UTF8
 
Constructor Summary
AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers ps)
           
AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers ps, javax.ws.rs.core.MediaType mt)
           
 
Method Summary
 boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
           
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
           
protected  Object readFrom(Class<Object> type, javax.ws.rs.core.MediaType mediaType, Unmarshaller u, InputStream entityStream)
          Unmarshal a JAXB type.
 Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, InputStream inputStream)
           
 void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)
           
protected  void writeTo(Object t, javax.ws.rs.core.MediaType mediaType, Charset c, Marshaller m, OutputStream entityStream)
          Marshal an instance of a JAXB type.
 
Methods inherited from class org.glassfish.jersey.message.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRootElementJaxbProvider

public AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers ps)

AbstractRootElementJaxbProvider

public AbstractRootElementJaxbProvider(javax.ws.rs.ext.Providers ps,
                                       javax.ws.rs.core.MediaType mt)
Method Detail

isReadable

public boolean isReadable(Class<?> type,
                          Type genericType,
                          Annotation[] annotations,
                          javax.ws.rs.core.MediaType mediaType)

isWriteable

public boolean isWriteable(Class<?> type,
                           Type genericType,
                           Annotation[] annotations,
                           javax.ws.rs.core.MediaType mediaType)

readFrom

public final Object readFrom(Class<Object> type,
                             Type genericType,
                             Annotation[] annotations,
                             javax.ws.rs.core.MediaType mediaType,
                             javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders,
                             InputStream inputStream)
                      throws IOException
Throws:
IOException

readFrom

protected Object readFrom(Class<Object> type,
                          javax.ws.rs.core.MediaType mediaType,
                          Unmarshaller u,
                          InputStream entityStream)
                   throws JAXBException
Unmarshal a JAXB type.

Implementing classes may override this method.

Parameters:
type - the JAXB type
mediaType - the media type
u - the unmarshaller to use for unmarshalling.
entityStream - the input stream to unmarshal from.
Returns:
an instance of the JAXB type.
Throws:
JAXBException

writeTo

public final void writeTo(Object t,
                          Class<?> type,
                          Type genericType,
                          Annotation[] annotations,
                          javax.ws.rs.core.MediaType mediaType,
                          javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
                          OutputStream entityStream)
                   throws IOException
Throws:
IOException

writeTo

protected void writeTo(Object t,
                       javax.ws.rs.core.MediaType mediaType,
                       Charset c,
                       Marshaller m,
                       OutputStream entityStream)
                throws JAXBException
Marshal an instance of a JAXB type.

Implementing classes may override this method.

Parameters:
t - the instance of the JAXB type.
mediaType - the meida 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:
JAXBException


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.