Class AbstractJaxbProvider<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractJaxbProvider​(javax.ws.rs.ext.Providers providers)
      Inheritance constructor.
      AbstractJaxbProvider​(javax.ws.rs.ext.Providers providers, javax.ws.rs.core.MediaType resolverMediaType)
      Inheritance constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private javax.xml.bind.JAXBContext getJAXBContext​(java.lang.Class type)  
      private javax.xml.bind.JAXBContext getJAXBContext​(java.lang.Class type, javax.ws.rs.core.MediaType mt)  
      private javax.xml.bind.Marshaller getMarshaller​(java.lang.Class type)  
      protected javax.xml.bind.Marshaller getMarshaller​(java.lang.Class type, javax.ws.rs.core.MediaType mediaType)
      Get the JAXB marshaller for the given class and media type.
      protected static javax.xml.transform.sax.SAXSource getSAXSource​(javax.xml.parsers.SAXParserFactory spf, java.io.InputStream entityStream)
      Create new SAXSource for a given entity input stream.
      protected javax.xml.bind.JAXBContext getStoredJaxbContext​(java.lang.Class type)
      Retrieve cached JAXB context capable of handling the given Java type.
      private javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class type)  
      protected javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class type, javax.ws.rs.core.MediaType mediaType)
      Get the JAXB unmarshaller for the given class and media type.
      protected boolean isFormattedOutput()  
      protected boolean isSupported​(javax.ws.rs.core.MediaType mediaType)
      Check if the given media type is supported by this JAXB entity provider.
      protected boolean isXmlRootElementProcessing()  
      void setConfiguration​(javax.ws.rs.core.Configuration config)  
      protected void setHeader​(javax.xml.bind.Marshaller marshaller, java.lang.annotation.Annotation[] annotations)
      Set the custom XML header on a JAXB marshaller if specified via XmlHeader annotation, present in the supplied array of annotations.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.ws.rs.ext.MessageBodyReader

        isReadable, readFrom
      • Methods inherited from interface javax.ws.rs.ext.MessageBodyWriter

        isWriteable, writeTo
    • Field Detail

      • jaxbContexts

        private static final java.util.Map<java.lang.Class<?>,​java.lang.ref.WeakReference<javax.xml.bind.JAXBContext>> jaxbContexts
      • jaxrsProviders

        private final javax.ws.rs.ext.Providers jaxrsProviders
      • fixedResolverMediaType

        private final boolean fixedResolverMediaType
      • mtContext

        private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.JAXBContext>> mtContext
      • mtUnmarshaller

        private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Unmarshaller>> mtUnmarshaller
      • mtMarshaller

        private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Marshaller>> mtMarshaller
      • formattedOutput

        private Value<java.lang.Boolean> formattedOutput
      • xmlRootElementProcessing

        private Value<java.lang.Boolean> xmlRootElementProcessing
    • Constructor Detail

      • AbstractJaxbProvider

        public AbstractJaxbProvider​(javax.ws.rs.ext.Providers providers)
        Inheritance constructor.
        Parameters:
        providers - JAX-RS providers.
      • AbstractJaxbProvider

        public AbstractJaxbProvider​(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

      • setConfiguration

        @Context
        public void setConfiguration​(javax.ws.rs.core.Configuration config)
      • isSupported

        protected boolean isSupported​(javax.ws.rs.core.MediaType mediaType)
        Check if the given media type is supported by this JAXB entity provider.

        Subclasses can override this method. Default implementation always returns true.

        Parameters:
        mediaType - media type to be checked for support.
        Returns:
        true if the media type is supported by the entity provider, false otherwise.
      • getUnmarshaller

        protected final javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class type,
                                                                    javax.ws.rs.core.MediaType mediaType)
                                                             throws javax.xml.bind.JAXBException
        Get the JAXB unmarshaller for the given class and media type.

        In case this provider instance has been created with a fixed resolver media type, the supplied media type argument will be ignored.

        Parameters:
        type - Java type to be unmarshalled.
        mediaType - entity media type.
        Returns:
        JAXB unmarshaller for the requested Java type, media type combination.
        Throws:
        javax.xml.bind.JAXBException - in case retrieving the unmarshaller fails with a JAXB exception.
      • getUnmarshaller

        private javax.xml.bind.Unmarshaller getUnmarshaller​(java.lang.Class type)
                                                     throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • getMarshaller

        protected final javax.xml.bind.Marshaller getMarshaller​(java.lang.Class type,
                                                                javax.ws.rs.core.MediaType mediaType)
                                                         throws javax.xml.bind.JAXBException
        Get the JAXB marshaller for the given class and media type.

        In case this provider instance has been created with a fixed resolver media type, the supplied media type argument will be ignored.

        Parameters:
        type - Java type to be marshalled.
        mediaType - entity media type.
        Returns:
        JAXB marshaller for the requested Java type, media type combination.
        Throws:
        javax.xml.bind.JAXBException - in case retrieving the marshaller fails with a JAXB exception.
      • getMarshaller

        private javax.xml.bind.Marshaller getMarshaller​(java.lang.Class type)
                                                 throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • getJAXBContext

        private javax.xml.bind.JAXBContext getJAXBContext​(java.lang.Class type,
                                                          javax.ws.rs.core.MediaType mt)
                                                   throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • getJAXBContext

        private javax.xml.bind.JAXBContext getJAXBContext​(java.lang.Class type)
                                                   throws javax.xml.bind.JAXBException
        Throws:
        javax.xml.bind.JAXBException
      • getStoredJaxbContext

        protected javax.xml.bind.JAXBContext getStoredJaxbContext​(java.lang.Class type)
                                                           throws javax.xml.bind.JAXBException
        Retrieve cached JAXB context capable of handling the given Java type.
        Parameters:
        type - Java type .
        Returns:
        JAXB context associated with the Java type.
        Throws:
        javax.xml.bind.JAXBException - in case the JAXB context retrieval fails.
      • getSAXSource

        protected static javax.xml.transform.sax.SAXSource getSAXSource​(javax.xml.parsers.SAXParserFactory spf,
                                                                        java.io.InputStream entityStream)
                                                                 throws javax.xml.bind.JAXBException
        Create new SAXSource for a given entity input stream.
        Parameters:
        spf - SAX parser factory to be used to create the SAX source.
        entityStream - entity input stream.
        Returns:
        new SAXSource representing the entity input stream.
        Throws:
        javax.xml.bind.JAXBException - in case SAX source creation fails.
      • isFormattedOutput

        protected boolean isFormattedOutput()
      • isXmlRootElementProcessing

        protected boolean isXmlRootElementProcessing()
      • setHeader

        protected void setHeader​(javax.xml.bind.Marshaller marshaller,
                                 java.lang.annotation.Annotation[] annotations)
        Set the custom XML header on a JAXB marshaller if specified via XmlHeader annotation, present in the supplied array of annotations.
        Parameters:
        marshaller - JAXB marshaller.
        annotations - array of annotations that MAY contain a XmlHeader annotation instance.