JacksonJsonProvider (Jackson JAX-RS 2.5.1-SNAPSHOT API)
Date: 2015-01-01

com.fasterxml.jackson.jaxrs.json

## Class JacksonJsonProvider

- java.lang.Object
- - com.fasterxml.jackson.jaxrs.base.ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>
  - - com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider

- All Implemented Interfaces:
    com.fasterxml.jackson.core.Versioned, javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>
  Direct Known Subclasses:
    JacksonJaxbJsonProvider

      @Provider
      public class JacksonJsonProvider
      extends ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>

  Basic implementation of JAX-RS abstractions (`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:

  - By explicitly passing mapper to use in constructor
  - By explictly setting mapper to use by `ProviderBase.setMapper(MAPPER)`
  - By defining JAX-RS `Provider` that returns `ObjectMapper`s.
  - By doing none of above, in which case a default mapper instance is constructed (and configured if configuration methods are called)
  The last method ("do nothing specific") is often good enough; explicit passing of Mapper is simple and explicit; and Provider-based method may make sense with Depedency Injection frameworks, or if Mapper has to be configured differently for different media types.

  Note that the default mapper instance will be automatically created if one of explicit configuration methods (like `ProviderBase.configure(com.fasterxml.jackson.jaxrs.cfg.JaxRSFeature, boolean)`) is called: if so, Provider-based introspection is NOT used, but the resulting Mapper is used as configured.

  Note: version 1.3 added a sub-class (`JacksonJaxbJsonProvider`) which 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)

  Author:
    Tatu Saloranta

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `_jsonpFunctionName` JSONP function name to use for automatic JSONP wrapping, if any; if null, no JSONP wrapping is done.
    `protected javax.ws.rs.ext.Providers` | `_providers` Injectable context object used to locate configured instance of `ObjectMapper` 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.
    `static String` | `MIME_JAVASCRIPT`
    `static String` | `MIME_JAVASCRIPT_MS`

    - ### Fields inherited from class com.fasterxml.jackson.jaxrs.base.ProviderBase

      `_cfgCheckCanDeserialize, _cfgCheckCanSerialize, _cfgCustomUntouchables, _defaultReadView, _defaultWriteView, _jaxRSFeatures, _mapperConfig, _noContentExceptionRef, _readers, _unreadableClasses, _untouchables, _unwritableClasses, _writers, CLASS_NAME_NO_CONTENT_EXCEPTION, DEFAULT_UNREADABLES, DEFAULT_UNTOUCHABLES, DEFAULT_UNWRITABLES, HEADER_CONTENT_TYPE_OPTIONS, JAXRS_FEATURE_DEFAULTS, NO_CONTENT_MESSAGE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JacksonJsonProvider()` Default constructor, usually used when provider is automatically configured to be used with JAX-RS implementation.
    `JacksonJsonProvider(Annotations... annotationsToUse)`
    `JacksonJsonProvider(com.fasterxml.jackson.databind.ObjectMapper mapper)`
    `JacksonJsonProvider(com.fasterxml.jackson.databind.ObjectMapper mapper, Annotations[] annotationsToUse)` Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected JsonEndpointConfig` | `_configForReading(com.fasterxml.jackson.databind.ObjectMapper mapper, Annotation[] annotations)` Deprecated. Since 2.3, use variant that takes explicit defaultView
    `protected JsonEndpointConfig` | `_configForReading(com.fasterxml.jackson.databind.ObjectReader reader, Annotation[] annotations)`
    `protected JsonEndpointConfig` | `_configForWriting(com.fasterxml.jackson.databind.ObjectMapper mapper, Annotation[] annotations)` Deprecated. Since 2.3, use variant that takes explicit defaultView
    `protected JsonEndpointConfig` | `_configForWriting(com.fasterxml.jackson.databind.ObjectWriter writer, Annotation[] annotations)`
    `protected com.fasterxml.jackson.databind.ObjectMapper` | `_locateMapperViaProvider(Class<?> type, javax.ws.rs.core.MediaType mediaType)`
    `protected boolean` | `hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)` Helper method used to check whether given media type is supported by this provider.
    `protected boolean` | `isJsonType(javax.ws.rs.core.MediaType mediaType)` Deprecated. Since 2.2 use `hasMatchingMediaType(MediaType)` instead
    `void` | `setJSONPFunctionName(String fname)`
    `com.fasterxml.jackson.core.Version` | `version()` Method that will return version information stored in and read from jar that contains this class.

    - ### Methods inherited from class com.fasterxml.jackson.jaxrs.base.ProviderBase

      `_addSuperTypes, _configForReading, _configForWriting, _containedIn, _createGenerator, _createNoContentException, _createParser, _findCustomUntouchable, _isSpecialReadable, _modifyHeaders, addUntouchable, checkCanDeserialize, checkCanSerialize, configure, configure, configure, configure, configure, disable, disable, disable, disable, disable, disable, enable, enable, enable, enable, enable, enable, findEncoding, findSuperTypes, findSuperTypes, getSize, hasMatchingMediaTypeForReading, hasMatchingMediaTypeForWriting, isEnabled, isReadable, isWriteable, locateMapper, readFrom, removeUntouchable, setAnnotationsToUse, setDefaultReadView, setDefaultView, setDefaultWriteView, setMapper, writeTo`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MIME_JAVASCRIPT

          public static final String MIME_JAVASCRIPT

      See Also:
        Constant Field Values

    - #### MIME_JAVASCRIPT_MS

          public static final String MIME_JAVASCRIPT_MS

      See Also:
        Constant Field Values

    - #### BASIC_ANNOTATIONS

          public static final Annotations[] BASIC_ANNOTATIONS

      Default annotation sets to use, if not explicitly defined during construction: only Jackson annotations are used for the base class. Sub-classes can use other settings.

    - #### _jsonpFunctionName

          protected String _jsonpFunctionName

      JSONP function name to use for automatic JSONP wrapping, if any; if null, no JSONP wrapping is done. Note that this is the default value that can be overridden on per-endpoint basis.

    - #### _providers

          @Context
          protected javax.ws.rs.ext.Providers _providers

      Injectable context object used to locate configured instance of `ObjectMapper` to use for actual serialization.

  - ### Constructor Detail

    - #### JacksonJsonProvider

          public JacksonJsonProvider()

      Default constructor, usually used when provider is automatically configured to be used with JAX-RS implementation.

    - #### JacksonJsonProvider

          public JacksonJsonProvider(Annotations... annotationsToUse)

      Parameters:
        `annotationsToUse` - Annotation set(s) to use for configuring data binding

    - #### JacksonJsonProvider

          public JacksonJsonProvider(com.fasterxml.jackson.databind.ObjectMapper mapper)

    - #### JacksonJsonProvider

          public JacksonJsonProvider(com.fasterxml.jackson.databind.ObjectMapper mapper,
                             Annotations[] annotationsToUse)

      Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.
      Parameters:
        `annotationsToUse` - Sets of annotations (Jackson, JAXB) that provider should support

  - ### Method Detail

    - #### version

          public com.fasterxml.jackson.core.Version version()

      Method that will return version information stored in and read from jar that contains this class.

    - #### setJSONPFunctionName

          public void setJSONPFunctionName(String fname)

    - #### isJsonType

          @Deprecated
          protected boolean isJsonType(javax.ws.rs.core.MediaType mediaType)

      Deprecated. Since 2.2 use `hasMatchingMediaType(MediaType)` instead

    - #### hasMatchingMediaType

          protected boolean hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)

      Helper method used to check whether given media type is supported by this provider. Current implementation essentially checks to see whether `MediaType.getSubtype()` returns "json" or something ending with "+json". Or "text/x-json" (since 2.3)
      Specified by:
        `hasMatchingMediaType` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`
      Since:
        2.2

    - #### _locateMapperViaProvider

          protected com.fasterxml.jackson.databind.ObjectMapper _locateMapperViaProvider(Class<?> type,
                                                                             javax.ws.rs.core.MediaType mediaType)

      Specified by:
        `_locateMapperViaProvider` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`

    - #### _configForReading

          protected JsonEndpointConfig _configForReading(com.fasterxml.jackson.databind.ObjectReader reader,
                                             Annotation[] annotations)

      Specified by:
        `_configForReading` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`

    - #### _configForWriting

          protected JsonEndpointConfig _configForWriting(com.fasterxml.jackson.databind.ObjectWriter writer,
                                             Annotation[] annotations)

      Specified by:
        `_configForWriting` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`

    - #### _configForReading

          @Deprecated
          protected JsonEndpointConfig _configForReading(com.fasterxml.jackson.databind.ObjectMapper mapper,
                                                        Annotation[] annotations)

      Deprecated. Since 2.3, use variant that takes explicit defaultView
      Overrides:
        `_configForReading` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`

    - #### _configForWriting

          @Deprecated
          protected JsonEndpointConfig _configForWriting(com.fasterxml.jackson.databind.ObjectMapper mapper,
                                                        Annotation[] annotations)

      Deprecated. Since 2.3, use variant that takes explicit defaultView
      Overrides:
        `_configForWriting` in class `ProviderBase<JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,JsonEndpointConfig,JsonMapperConfigurator>`

Copyright © 2014–2015 FasterXML. All rights reserved.