T
- Java type supported by the provider.public abstract class AbstractJaxbProvider<T> extends AbstractMessageReaderWriterProvider<T>
Modifier and Type | Field and Description |
---|---|
private boolean |
fixedResolverMediaType |
private Value<java.lang.Boolean> |
formattedOutput |
private static java.util.Map<java.lang.Class<?>,java.lang.ref.WeakReference<javax.xml.bind.JAXBContext>> |
jaxbContexts |
private javax.ws.rs.ext.Providers |
jaxrsProviders |
private Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.JAXBContext>> |
mtContext |
private Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Marshaller>> |
mtMarshaller |
private Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Unmarshaller>> |
mtUnmarshaller |
private Value<java.lang.Boolean> |
xmlRootElementProcessing |
UTF8
Constructor and 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.
|
Modifier and Type | Method and 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. |
getCharset, getSize, readFromAsString, writeTo, writeTo, writeToAsString
private static final java.util.Map<java.lang.Class<?>,java.lang.ref.WeakReference<javax.xml.bind.JAXBContext>> jaxbContexts
private final javax.ws.rs.ext.Providers jaxrsProviders
private final boolean fixedResolverMediaType
private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.JAXBContext>> mtContext
private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Unmarshaller>> mtUnmarshaller
private final Value<javax.ws.rs.ext.ContextResolver<javax.xml.bind.Marshaller>> mtMarshaller
private Value<java.lang.Boolean> formattedOutput
private Value<java.lang.Boolean> xmlRootElementProcessing
public AbstractJaxbProvider(javax.ws.rs.ext.Providers providers)
providers
- JAX-RS providers.public AbstractJaxbProvider(javax.ws.rs.ext.Providers providers, javax.ws.rs.core.MediaType resolverMediaType)
providers
- JAX-RS providers.resolverMediaType
- JAXB component context resolver media type to be used.@Context public void setConfiguration(javax.ws.rs.core.Configuration config)
protected boolean isSupported(javax.ws.rs.core.MediaType mediaType)
Subclasses can override this method. Default implementation always returns true
.
mediaType
- media type to be checked for support.true
if the media type is supported by the entity provider, false
otherwise.protected final javax.xml.bind.Unmarshaller getUnmarshaller(java.lang.Class type, javax.ws.rs.core.MediaType mediaType) throws javax.xml.bind.JAXBException
In case this provider instance has been created with a fixed resolver media type
, the supplied media type argument will be ignored.
type
- Java type to be unmarshalled.mediaType
- entity media type.javax.xml.bind.JAXBException
- in case retrieving the unmarshaller fails with a JAXB exception.private javax.xml.bind.Unmarshaller getUnmarshaller(java.lang.Class type) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
protected final javax.xml.bind.Marshaller getMarshaller(java.lang.Class type, javax.ws.rs.core.MediaType mediaType) throws javax.xml.bind.JAXBException
In case this provider instance has been created with a fixed resolver media type
, the supplied media type argument will be ignored.
type
- Java type to be marshalled.mediaType
- entity media type.javax.xml.bind.JAXBException
- in case retrieving the marshaller fails with a JAXB exception.private javax.xml.bind.Marshaller getMarshaller(java.lang.Class type) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
private javax.xml.bind.JAXBContext getJAXBContext(java.lang.Class type, javax.ws.rs.core.MediaType mt) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
private javax.xml.bind.JAXBContext getJAXBContext(java.lang.Class type) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
protected javax.xml.bind.JAXBContext getStoredJaxbContext(java.lang.Class type) throws javax.xml.bind.JAXBException
type
- Java type .javax.xml.bind.JAXBException
- in case the JAXB context retrieval fails.protected static javax.xml.transform.sax.SAXSource getSAXSource(javax.xml.parsers.SAXParserFactory spf, java.io.InputStream entityStream) throws javax.xml.bind.JAXBException
SAXSource
for a given entity input stream.spf
- SAX parser factory to be used to create the SAX source.entityStream
- entity input stream.SAXSource
representing the entity input stream.javax.xml.bind.JAXBException
- in case SAX source creation fails.protected boolean isFormattedOutput()
protected boolean isXmlRootElementProcessing()
protected void setHeader(javax.xml.bind.Marshaller marshaller, java.lang.annotation.Annotation[] annotations)
XmlHeader
annotation,
present in the supplied array of annotations.marshaller
- JAXB marshaller.annotations
- array of annotations that MAY contain a XmlHeader
annotation instance.