Top Description Fields Constructors Methods
com.fasterxml.jackson.jakarta.rs.cbor

public Class JacksonCBORProvider

extends ProviderBase<JacksonCBORProvider, ObjectMapper, CBOREndpointConfig, CBORMapperConfigurator>
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.jakarta.rs.cbor.JacksonXmlBindCBORProvider
Annotations
@Provider
@Consumes:*/*
@Produces:application/cbor, */*
Imports
java.lang.annotation.Annotation, jakarta.ws.rs.*, jakarta.ws.rs.core.*, jakarta.ws.rs.ext.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.dataformat.cbor.CBORFactory, com.fasterxml.jackson.jakarta.rs.base.ProviderBase, com.fasterxml.jackson.jakarta.rs.cfg.Annotations

Basic implementation of Jakarta-RS abstractions (MessageBodyReader, MessageBodyWriter) needed for binding CBOR ("application/cbor") 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:

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 Dependency 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 configure) 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 -- (JacksonXmlBindCBORProvider) -- that is configured by default to use both Jackson and Jakarta XmlBind annotations for configuration (base class when used as-is defaults to using just Jackson annotations)

Author
Tatu Saloranta

Field Summary

Modifier and TypeField and Description
protected Providers
_providers

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

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.

Inherited from com.fasterxml.jackson.jakarta.rs.base.ProviderBase:
_cfgCheckCanDeserialize_cfgCheckCanSerialize_cfgCustomUntouchables_defaultReadView_defaultWriteView_jakartaRSFeatures_mapperConfig_readers_unreadableClasses_untouchables_unwritableClasses_writersDEFAULT_UNREADABLESDEFAULT_UNTOUCHABLESDEFAULT_UNWRITABLESHEADER_CONTENT_TYPE_OPTIONSJAKARTA_RS_FEATURE_DEFAULTS

Constructor Summary

AccessConstructor and Description
public
JacksonCBORProvider()

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

public
JacksonCBORProvider(Annotations...
Annotation set(s) to use for configuring data binding
annotationsToUse
)

public
public
JacksonCBORProvider(ObjectMapper mapper, Annotations[]
Sets of annotations (Jackson, XmlBind) that provider should support
annotationsToUse
)

Constructor to use when a custom mapper (usually components like serializer/deserializer factories that have been configured) is to be used.

Method Summary

Modifier and TypeMethod and Description
protected CBOREndpointConfig
protected CBOREndpointConfig
protected ObjectMapper
_locateMapperViaProvider(Class<?>
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.
type
,
MediaType
Declared media type for the instance to process: not used by this method, but will be passed to ContextResolver as is.
mediaType
)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase._locateMapperViaProvider.

Method called to locate ObjectMapper to use for serialization and deserialization.

protected boolean
hasMatchingMediaType(MediaType mediaType)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase.hasMatchingMediaType.

Helper method used to check whether given media type is CBOR type or sub type.

public Version
version()

Implements com.fasterxml.jackson.core.Versioned.version.

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

Inherited from com.fasterxml.jackson.jakarta.rs.base.ProviderBase:
_addSuperTypes_configForReading_configForWriting_containedIn_createGenerator_createNoContentException_createParser_endpointForReading_endpointForWriting_findCustomUntouchable_isIgnorableForReading_isIgnorableForWriting_isSpecialReadable_modifyHeadersaddUntouchablecheckCanDeserializecheckCanSerializeconfigureconfigureconfigureconfigureconfiguredisabledisabledisabledisabledisabledisableenableenableenableenableenableenablefindEncodingfindSuperTypesfindSuperTypesgetSizehasMatchingMediaTypeForReadinghasMatchingMediaTypeForWritingisEnabledisReadableisWriteablelocateMapperreadFromremoveUntouchablesetAnnotationsToUsesetDefaultReadViewsetDefaultViewsetDefaultWriteViewsetMapperwriteTo

Field Detail

_providersback to summary
protected Providers _providers

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

Annotations
@Context
BASIC_ANNOTATIONSback to summary
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.

Constructor Detail

JacksonCBORProviderback to summary
public JacksonCBORProvider()

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

JacksonCBORProviderback to summary
public JacksonCBORProvider(Annotations... annotationsToUse)
Parameters
annotationsToUse:Annotations[]

Annotation set(s) to use for configuring data binding

JacksonCBORProviderback to summary
public JacksonCBORProvider(ObjectMapper mapper)
JacksonCBORProviderback to summary
public JacksonCBORProvider(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:Annotations[]

Sets of annotations (Jackson, XmlBind) that provider should support

Method Detail

_configForReadingback to summary
protected CBOREndpointConfig _configForReading(ObjectReader reader, Annotation[] annotations)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase._configForReading.

Annotations
@Override
_configForWritingback to summary
protected CBOREndpointConfig _configForWriting(ObjectWriter writer, Annotation[] annotations)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase._configForWriting.

Annotations
@Override
_locateMapperViaProviderback to summary
protected ObjectMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase._locateMapperViaProvider.

Method called to locate ObjectMapper to use for serialization and deserialization. If an instance has been explicitly defined by setMapper (or non-null instance passed in constructor), that will be used. If not, will try to locate it using standard Jakarta-RS ContextResolver mechanism, if it has been properly configured to access it (by Jakarta-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)

Parameters
type:Class<?>

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:MediaType

Declared media type for the instance to process: not used by this method, but will be passed to ContextResolver as is.

Annotations
@Override
hasMatchingMediaTypeback to summary
protected boolean hasMatchingMediaType(MediaType mediaType)

Implements abstract com.fasterxml.jackson.jakarta.rs.base.ProviderBase.hasMatchingMediaType.

Helper method used to check whether given media type is CBOR type or sub type. Current implementation essentially checks to see whether MediaType#getSubtype returns "cbor" or something ending with "+cbor".

Annotations
@Override
versionback to summary
public Version version()

Implements com.fasterxml.jackson.core.Versioned.version.

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

Returns:Version

Doc from com.fasterxml.jackson.core.Versioned.version.

Version of the component

Annotations
@Override