@Provider public class JacksonXMLProvider extends ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>
MessageBodyReader,
MessageBodyWriter) needed for binding
JSON ("application/json") content to and from Java Objects ("POJO"s).
Actual data binding functionality is implemented by ObjectMapper:
mapper to use can be configured in multiple ways:
ProviderBase.setMapper(MAPPER)
Provider that returns XmlMappers.
Note that the default mapper instance will be automatically created if
one of explicit configuration methods (like ProviderBase.configure(com.fasterxml.jackson.databind.DeserializationFeature, boolean))
is called: if so, Provider-based introspection is NOT used, but the
resulting Mapper is used as configured.
Note that there is also a sub-class -- (JacksonJaxbXMLProvider) -- that
is configured by default to use both Jackson and JAXB annotations for configuration
(base class when used as-is defaults to using just Jackson annotations)
| Modifier and Type | Field and Description |
|---|---|
protected javax.ws.rs.ext.Providers |
_providers
Injectable context object used to locate configured
instance of
XmlMapper to use for actual
serialization. |
static Annotations[] |
BASIC_ANNOTATIONS
Default annotation sets to use, if not explicitly defined during
construction: only Jackson annotations are used for the base
class.
|
_cfgCheckCanDeserialize, _cfgCheckCanSerialize, _cfgCustomUntouchables, _mapperConfig, _readers, _unreadableClasses, _untouchables, _unwritableClasses, _writers, DEFAULT_UNREADABLES, DEFAULT_UNTOUCHABLES, DEFAULT_UNWRITABLES| Constructor and Description |
|---|
JacksonXMLProvider()
Default constructor, usually used when provider is automatically
configured to be used with JAX-RS implementation.
|
JacksonXMLProvider(Annotations... annotationsToUse) |
JacksonXMLProvider(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper) |
JacksonXMLProvider(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper,
Annotations[] annotationsToUse)
Constructor to use when a custom mapper (usually components
like serializer/deserializer factories that have been configured)
is to be used.
|
| Modifier and Type | Method and Description |
|---|---|
protected XMLEndpointConfig |
_configForReading(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper,
Annotation[] annotations) |
protected XMLEndpointConfig |
_configForWriting(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper,
Annotation[] annotations) |
protected com.fasterxml.jackson.core.JsonParser |
_createParser(com.fasterxml.jackson.databind.ObjectReader reader,
InputStream rawStream)
Overridable helper method called to create a
JsonParser for reading
contents of given raw InputStream. |
com.fasterxml.jackson.dataformat.xml.XmlMapper |
_locateMapperViaProvider(Class<?> type,
javax.ws.rs.core.MediaType mediaType)
Method called to locate
XmlMapper to use for serialization
and deserialization. |
protected boolean |
hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
Helper method used to check whether given media type
is XML type or sub type.
|
protected boolean |
isXMLType(javax.ws.rs.core.MediaType mediaType)
Deprecated.
Since 2.2 use
hasMatchingMediaType(MediaType) instead |
com.fasterxml.jackson.core.Version |
version()
Method that will return version information stored in and read from jar
that contains this class.
|
_addSuperTypes, _containedIn, _findCustomUntouchable, _isSpecialReadable, addUntouchable, checkCanDeserialize, checkCanSerialize, configure, configure, configure, configure, disable, disable, disable, disable, enable, enable, enable, enable, findEncoding, findSuperTypes, findSuperTypes, getSize, isReadable, isWriteable, locateMapper, readFrom, removeUntouchable, setAnnotationsToUse, setMapper, writeTopublic static final Annotations[] BASIC_ANNOTATIONS
@Context protected javax.ws.rs.ext.Providers _providers
XmlMapper to use for actual
serialization.public JacksonXMLProvider()
public JacksonXMLProvider(Annotations... annotationsToUse)
annotationsToUse - Annotation set(s) to use for configuring
data bindingpublic JacksonXMLProvider(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper)
public JacksonXMLProvider(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper,
Annotations[] annotationsToUse)
annotationsToUse - Sets of annotations (Jackson, JAXB) that provider should
supportpublic com.fasterxml.jackson.core.Version version()
protected XMLEndpointConfig _configForReading(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper, Annotation[] annotations)
_configForReading in class ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>protected XMLEndpointConfig _configForWriting(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper, Annotation[] annotations)
_configForWriting in class ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>@Deprecated protected boolean isXMLType(javax.ws.rs.core.MediaType mediaType)
hasMatchingMediaType(MediaType) insteadprotected boolean hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
MediaType.getSubtype() returns "xml" or something
ending with "+xml".hasMatchingMediaType in class ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>public com.fasterxml.jackson.dataformat.xml.XmlMapper _locateMapperViaProvider(Class<?> type, javax.ws.rs.core.MediaType mediaType)
XmlMapper to use for serialization
and deserialization. If an instance has been explicitly defined by
ProviderBase.setMapper(MAPPER) (or non-null instance passed in constructor), that
will be used.
If not, will try to locate it using standard JAX-RS
ContextResolver mechanism, if it has been properly configured
to access it (by JAX-RS runtime).
Finally, if no mapper is found, will return a default unconfigured
ObjectMapper instance (one constructed with default constructor
and not modified in any way)_locateMapperViaProvider in class ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>type - Class of object being serialized or deserialized;
not checked at this point, since it is assumed that unprocessable
classes have been already weeded out,
but will be passed to ContextResolver as is.mediaType - Declared media type for the instance to process:
not used by this method,
but will be passed to ContextResolver as is.protected com.fasterxml.jackson.core.JsonParser _createParser(com.fasterxml.jackson.databind.ObjectReader reader,
InputStream rawStream)
throws IOException
ProviderBaseJsonParser for reading
contents of given raw InputStream.
May return null to indicate that Stream is empty; that is, contains no
content._createParser in class ProviderBase<JacksonXMLProvider,com.fasterxml.jackson.dataformat.xml.XmlMapper,XMLEndpointConfig,XMLMapperConfigurator>IOExceptionCopyright © 2012-2013 FasterXML. All Rights Reserved.