Package org.apache.cxf.jaxrs.provider
Class AbstractJAXBProvider<T>
java.lang.Object
org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
org.apache.cxf.jaxrs.provider.AbstractJAXBProvider<T>
- All Implemented Interfaces:
jakarta.ws.rs.ext.MessageBodyReader<T>
,jakarta.ws.rs.ext.MessageBodyWriter<T>
- Direct Known Subclasses:
JAXBElementProvider
public abstract class AbstractJAXBProvider<T>
extends AbstractConfigurableProvider
implements jakarta.ws.rs.ext.MessageBodyReader<T>, jakarta.ws.rs.ext.MessageBodyWriter<T>
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected static final String
protected static final String
protected boolean
protected boolean
Fields inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
BUNDLE, LOG
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
canBeReadAsJaxbElement
(Class<?> type) protected static Object
checkAdapter
(Object obj, Class<?> cls, Annotation[] anns, boolean marshal) void
protected XMLStreamReader
protected Object
convertToJaxbElementIfNeeded
(Object obj, Class<?> cls, Type genericType) protected XMLStreamReader
createDepthReaderIfNeeded
(XMLStreamReader reader, InputStream is) protected jakarta.xml.bind.Marshaller
createMarshaller
(Object obj, Class<?> cls, Type genericType, String enc) protected XMLStreamReader
createTransformReaderIfNeeded
(XMLStreamReader reader, InputStream is) protected XMLStreamWriter
createTransformWriterIfNeeded
(XMLStreamWriter writer, OutputStream os, boolean dropAtXmlLevel) protected jakarta.xml.bind.Unmarshaller
createUnmarshaller
(Class<?> cls, Type genericType) protected jakarta.xml.bind.Unmarshaller
createUnmarshaller
(Class<?> cls, Type genericType, boolean isCollection) protected Class<?>
getActualType
(Class<?> type, Type genericType, Annotation[] anns) jakarta.xml.bind.JAXBContext
getClassContext
(Class<?> type) protected jakarta.xml.bind.JAXBContext
getClassContext
(Class<?> type, Type genericType) protected jakarta.xml.bind.JAXBContext
getCollectionContext
(Class<?> type) protected QName
getCollectionWrapperQName
(Class<?> cls, Type type, Object object, boolean pluralName) protected MessageContext
protected org.apache.cxf.staxutils.DocumentDepthProperties
jakarta.xml.bind.JAXBContext
getJAXBContext
(Class<?> type, Type genericType) protected Class<?>
getJaxbElementClass
(Class<?> cls) protected QName
getJaxbQName
(Class<?> cls, Type type, Object object, boolean pluralName) jakarta.xml.bind.JAXBContext
getPackageContext
(Class<?> type) protected jakarta.xml.bind.JAXBContext
getPackageContext
(Class<?> type, Type genericType) protected Schema
protected Schema
long
getSize
(T o, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mt) protected <X> X
getStreamHandlerFromCurrentMessage
(Class<X> staxCls) protected static void
handleExceptionEnd
(Throwable t, String message, boolean read) protected static StringBuilder
protected void
handleJAXBException
(jakarta.xml.bind.JAXBException e, boolean read) protected void
handleXMLStreamException
(XMLStreamException e, boolean read) void
init
(List<ClassResourceInfo> cris) Gives providers a chance to introspect the JAX-RS model classes.boolean
isReadable
(Class<?> type, Type genericType, Annotation[] anns, jakarta.ws.rs.core.MediaType mt) boolean
protected boolean
isSupported
(Class<?> type, Type genericType, Annotation[] anns) boolean
isWriteable
(Class<?> type, Type genericType, Annotation[] anns, jakarta.ws.rs.core.MediaType mt) protected boolean
protected boolean
protected boolean
objectFactoryOrIndexAvailable
(Class<?> type) void
setAttributesToElements
(boolean value) void
setCatalogLocation
(String name) void
void
setCollectionWrapperName
(String wName) protected void
setContext
(MessageContext context) void
setContextProperties
(Map<String, Object> contextProperties) void
setDepthProperties
(org.apache.cxf.staxutils.DocumentDepthProperties depthProperties) void
setExtraClass
(Class<?>[] userExtraClass) void
setInAppendElements
(Map<String, String> inElements) void
setInDropElements
(List<String> dropElementsSet) void
setInTransformElements
(Map<String, String> inElements) void
void
setJaxbElementClassNames
(List<String> names) void
setMarshallAsJaxbElement
(boolean value) void
setMarshallerListener
(jakarta.xml.bind.Marshaller.Listener marshallerListener) protected static void
setMarshallerProp
(jakarta.xml.bind.Marshaller ms, Object value, String name1, String name2) protected void
setNamespaceMapper
(jakarta.xml.bind.Marshaller ms, Map<String, String> map) void
setNamespaceMapperPropertyName
(String namespaceMapperProperty) void
setOutAppendElements
(Map<String, String> map) void
setOutDropElements
(List<String> dropElementsSet) void
setOutTransformElements
(Map<String, String> outElements) protected void
void
setSchemaHandler
(SchemaHandler handler) void
setSchemaHandlers
(Map<String, SchemaHandler> handlers) void
setSchemaLocations
(List<String> locations) void
setSingleJaxbContext
(boolean useSingleContext) void
setSkipJaxbChecks
(boolean skipJaxbChecks) void
setUnmarshallAsJaxbElement
(boolean value) void
setUnmarshallerListener
(jakarta.xml.bind.Unmarshaller.Listener unmarshallerListener) void
setUnmarshallerProperties
(Map<String, Object> unmarshalProperties) void
setUseSingleContextForPackages
(boolean use) void
setValidateBeforeWrite
(boolean validateBeforeWrite) void
setValidateInput
(boolean validateInput) void
setValidateOutput
(boolean validateOutput) void
setValidationHandler
(jakarta.xml.bind.ValidationEventHandler handler) void
setXmlRootAsJaxbElement
(boolean xmlRootAsJaxbElement) void
setXmlTypeAsJaxbElementOnly
(boolean value) protected void
validateObjectIfNeeded
(jakarta.xml.bind.Marshaller marshaller, Class<?> cls, Object obj) void
writeTo
(T t, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) Methods inherited from class org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider
getBus, getConsumeMediaTypes, getEnableBuffering, getEnableStreaming, getProduceMediaTypes, isPayloadEmpty, isPayloadEmpty, reportEmptyContentLength, setBus, setConsumeMediaTypes, setEnableBuffering, setEnableStreaming, setProduceMediaTypes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.ws.rs.ext.MessageBodyReader
readFrom
Methods inherited from interface jakarta.ws.rs.ext.MessageBodyWriter
writeTo
-
Field Details
-
NS_MAPPER_PROPERTY_RI
- See Also:
-
NS_MAPPER_PROPERTY_RI_INT
- See Also:
-
collectionContextClasses
-
jaxbElementClassMap
-
objectFactoryOrIndexMap
-
unmarshalAsJaxbElement
protected boolean unmarshalAsJaxbElement -
marshalAsJaxbElement
protected boolean marshalAsJaxbElement -
xmlTypeAsJaxbElementOnly
protected boolean xmlTypeAsJaxbElementOnly -
outElementsMap
-
outAppendMap
-
outDropElements
-
inDropElements
-
inElementsMap
-
inAppendMap
-
packageContexts
-
classContexts
-
-
Constructor Details
-
AbstractJAXBProvider
public AbstractJAXBProvider()
-
-
Method Details
-
setXmlRootAsJaxbElement
public void setXmlRootAsJaxbElement(boolean xmlRootAsJaxbElement) -
setNamespaceMapper
protected void setNamespaceMapper(jakarta.xml.bind.Marshaller ms, Map<String, String> map) throws Exception- Throws:
Exception
-
setMarshallerProp
protected static void setMarshallerProp(jakarta.xml.bind.Marshaller ms, Object value, String name1, String name2) throws Exception - Throws:
Exception
-
setValidationHandler
public void setValidationHandler(jakarta.xml.bind.ValidationEventHandler handler) -
setSingleJaxbContext
public void setSingleJaxbContext(boolean useSingleContext) -
setUseSingleContextForPackages
public void setUseSingleContextForPackages(boolean use) -
setExtraClass
-
init
Description copied from class:AbstractConfigurableProvider
Gives providers a chance to introspect the JAX-RS model classes. For example, the JAXB provider may use the model classes to create a single composite JAXBContext supporting all the JAXB-annotated root resource classes/types.- Overrides:
init
in classAbstractConfigurableProvider
-
setContextProperties
-
setUnmarshallerProperties
-
setUnmarshallAsJaxbElement
public void setUnmarshallAsJaxbElement(boolean value) -
setMarshallAsJaxbElement
public void setMarshallAsJaxbElement(boolean value) -
setXmlTypeAsJaxbElementOnly
public void setXmlTypeAsJaxbElementOnly(boolean value) -
setJaxbElementClassNames
-
setJaxbElementClassMap
-
getStreamHandlerFromCurrentMessage
-
isXmlRoot
-
isXmlType
-
convertToJaxbElementIfNeeded
protected Object convertToJaxbElementIfNeeded(Object obj, Class<?> cls, Type genericType) throws Exception - Throws:
Exception
-
getJaxbElementClass
-
setCollectionWrapperName
-
setCollectionWrapperMap
-
setContext
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, jakarta.ws.rs.core.MediaType mt) - Specified by:
isWriteable
in interfacejakarta.ws.rs.ext.MessageBodyWriter<T>
-
writeTo
public void writeTo(T t, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, jakarta.ws.rs.WebApplicationException- Throws:
IOException
jakarta.ws.rs.WebApplicationException
-
getCollectionContext
protected jakarta.xml.bind.JAXBContext getCollectionContext(Class<?> type) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getCollectionWrapperQName
protected QName getCollectionWrapperQName(Class<?> cls, Type type, Object object, boolean pluralName) throws Exception - Throws:
Exception
-
getJaxbQName
protected QName getJaxbQName(Class<?> cls, Type type, Object object, boolean pluralName) throws Exception - Throws:
Exception
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, jakarta.ws.rs.core.MediaType mt) - Specified by:
isReadable
in interfacejakarta.ws.rs.ext.MessageBodyReader<T>
-
canBeReadAsJaxbElement
-
setSchemaLocations
-
setCatalogLocation
-
setSchemaHandler
-
setSchemaHandlers
-
setSchema
-
getSize
public long getSize(T o, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mt) - Specified by:
getSize
in interfacejakarta.ws.rs.ext.MessageBodyWriter<T>
-
getContext
-
getJAXBContext
public jakarta.xml.bind.JAXBContext getJAXBContext(Class<?> type, Type genericType) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getClassContext
public jakarta.xml.bind.JAXBContext getClassContext(Class<?> type) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getClassContext
protected jakarta.xml.bind.JAXBContext getClassContext(Class<?> type, Type genericType) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getPackageContext
-
getPackageContext
-
isSupported
-
objectFactoryOrIndexAvailable
-
createUnmarshaller
protected jakarta.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls, Type genericType) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
createUnmarshaller
protected jakarta.xml.bind.Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
createMarshaller
protected jakarta.xml.bind.Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
validateObjectIfNeeded
protected void validateObjectIfNeeded(jakarta.xml.bind.Marshaller marshaller, Class<?> cls, Object obj) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getActualType
-
checkAdapter
-
getSchema
-
getSchema
-
clearContexts
public void clearContexts() -
handleExceptionStart
-
handleExceptionEnd
-
handleJAXBException
protected void handleJAXBException(jakarta.xml.bind.JAXBException e, boolean read) -
handleXMLStreamException
-
setOutTransformElements
-
setInAppendElements
-
setInTransformElements
-
setOutAppendElements
-
setOutDropElements
-
setInDropElements
-
setAttributesToElements
public void setAttributesToElements(boolean value) -
setSkipJaxbChecks
public void setSkipJaxbChecks(boolean skipJaxbChecks) -
isSkipJaxbChecks
public boolean isSkipJaxbChecks() -
createTransformWriterIfNeeded
protected XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writer, OutputStream os, boolean dropAtXmlLevel) -
createTransformReaderIfNeeded
-
createDepthReaderIfNeeded
-
configureReaderRestrictions
-
getDepthProperties
protected org.apache.cxf.staxutils.DocumentDepthProperties getDepthProperties() -
setValidateBeforeWrite
public void setValidateBeforeWrite(boolean validateBeforeWrite) -
setValidateOutput
public void setValidateOutput(boolean validateOutput) -
setValidateInput
public void setValidateInput(boolean validateInput) -
setDepthProperties
public void setDepthProperties(org.apache.cxf.staxutils.DocumentDepthProperties depthProperties) -
setUnmarshallerListener
public void setUnmarshallerListener(jakarta.xml.bind.Unmarshaller.Listener unmarshallerListener) -
setMarshallerListener
public void setMarshallerListener(jakarta.xml.bind.Marshaller.Listener marshallerListener) -
setNamespaceMapperPropertyName
-