Top Fields Constructors Methods
com.fasterxml.jackson.jakarta.rs.base

public abstract Class ProviderBase<THIS extends ProviderBase<THIS, MAPPER, EP_CONFIG, MAPPER_CONFIG>, MAPPER extends ObjectMapper, EP_CONFIG extends EndpointConfigBase<EP_CONFIG>, MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG, MAPPER>>

extends Object
implements MessageBodyReader<Object>, MessageBodyWriter<Object>, Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned, jakarta.ws.rs.ext.MessageBodyWriter, jakarta.ws.rs.ext.MessageBodyReader
Imports
java.io.*, java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.*, jakarta.ws.rs.core.*, jakarta.ws.rs.ext.MessageBodyReader, .MessageBodyWriter, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.type.TypeFactory, com.fasterxml.jackson.databind.util.LRUMap, .LookupCache, com.fasterxml.jackson.jakarta.rs.base.util.ClassKey, com.fasterxml.jackson.jakarta.rs.cfg.*

Field Summary

Modifier and TypeField and Description
protected boolean
_cfgCheckCanDeserialize

Whether we want to actually check that Jackson has a deserializer for given type.

protected boolean
_cfgCheckCanSerialize

Whether we want to actually check that Jackson has a serializer for given type.

protected HashMap<ClassKey, Boolean>
_cfgCustomUntouchables

Map that contains overrides to default list of untouchable types: true meaning that entry is untouchable, false that is is not.

protected Class<?>
_defaultReadView

View to use for reading if none defined for the end point.

protected Class<?>
_defaultWriteView

View to use for writing if none defined for the end point.

protected int
_jakartaRSFeatures

Feature flags set.

protected final MAPPER_CONFIG
_mapperConfig

Helper object used for encapsulating configuration aspects of ObjectMapper

protected final LookupCache<AnnotationBundleKey, EP_CONFIG>
_readers

Cache for resolved endpoint configurations when reading JSON data

public static final Class<?>[]
public static final HashSet<ClassKey>
public static final Class<?>[]
protected final LookupCache<AnnotationBundleKey, EP_CONFIG>
_writers

Cache for resolved endpoint configurations when writing JSON data

public static final Class<?>[]
DEFAULT_UNREADABLES

These are classes that we never use for reading (never try to deserialize instances of these types).

protected static final HashSet<ClassKey>
DEFAULT_UNTOUCHABLES

Looks like we need to worry about accidental data binding for types we shouldn't be handling.

public static final Class<?>[]
DEFAULT_UNWRITABLES

These are classes that we never use for writing (never try to serialize instances of these types).

public static final String
HEADER_CONTENT_TYPE_OPTIONS

This header is useful on Windows, trying to deal with potential XSS attacks.

protected static final int
private static final String

Constructor Summary

AccessConstructor and Description
protected
ProviderBase(MAPPER_CONFIG mconfig)

protected
ProviderBase()
Deprecated

Constructor that is only added to resolve problems with combination of RESTeasy and CDI.

protected
ProviderBase(MAPPER_CONFIG mconfig, LookupCache<AnnotationBundleKey, EP_CONFIG> readerCache, LookupCache<AnnotationBundleKey, EP_CONFIG> writerCache)

Method Summary

Modifier and TypeMethod and Description
protected static void
_addSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself)

protected EP_CONFIG
_configForReading(MAPPER mapper, Annotation[] annotations, Class<?> defaultView)

protected abstract EP_CONFIG
_configForReading(ObjectReader reader, Annotation[] annotations)

protected EP_CONFIG
_configForWriting(MAPPER mapper, Annotation[] annotations, Class<?> defaultView)

protected abstract EP_CONFIG
_configForWriting(ObjectWriter writer, Annotation[] annotations)

protected static boolean
_containedIn(Class<?> mainType, HashSet<ClassKey> set)

protected JsonGenerator
_createGenerator(ObjectWriter writer, OutputStream rawStream, JsonEncoding enc)

Overridable helper method called to create a JsonGenerator for writing contents into given raw OutputStream.

protected IOException
protected JsonParser
_createParser(ObjectReader reader, InputStream rawStream)

Overridable helper method called to create a JsonParser for reading contents of given raw InputStream.

protected EP_CONFIG
_endpointForReading(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders)

Overridable helper method that will basically fetch representation of the endpoint that can be used to get ObjectReader to use for deserializing content

protected EP_CONFIG
_endpointForWriting(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders)

protected Boolean
protected boolean
_isIgnorableForReading(ClassKey typeKey)

Overridable helper method called to check whether given type is a known "ignorable type" (in context of reading), values of which are not bound from content.

protected boolean
_isIgnorableForWriting(ClassKey typeKey)

Overridable helper method called to check whether given type is a known "ignorable type" (in context of reading), values of which can not be written out.

protected boolean
_isSpecialReadable(Class<?> type)

Overridable helper method used to allow handling of somewhat special types for reading

protected abstract MAPPER
_locateMapperViaProvider(Class<?> type, MediaType mediaType)

Helper method that is called if no mapper has been explicitly configured.

protected void
_modifyHeaders(Object value, Class<?> type, Type genericType, Annotation[] annotations, MultivaluedMap<String, Object> httpHeaders, EP_CONFIG endpoint)

Overridable method used for adding optional response headers before serializing response object.

private final THIS
public void
addUntouchable(Class<?>
Type to consider untouchable; can be any kind of class, including abstract class or interface. No instance of this type (including subtypes, i.e. types assignable to this type) will be read or written by provider
type
)

Method for marking specified type as "untouchable", meaning that provider will not try to read or write values of this type (or its subtypes).

public void
checkCanDeserialize(boolean state)

Method for defining whether actual detection for existence of a deserializer for type should be done when isReadable is called.

public void
checkCanSerialize(boolean state)

Method for defining whether actual detection for existence of a serializer for type should be done when isWriteable is called.

public THIS
configure(JakartaRSFeature feature, boolean state)

public THIS
public THIS
configure(SerializationFeature f, boolean state)

public THIS
configure(JsonParser.Feature f, boolean state)

public THIS
configure(JsonGenerator.Feature f, boolean state)

public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
public THIS
protected JsonEncoding
findEncoding(MediaType mediaType, MultivaluedMap<String, Object> httpHeaders)

Helper method to use for determining desired output encoding.

protected static List<Class<?>>
findSuperTypes(Class<?> cls, Class<?> endBefore)

protected static List<Class<?>>
findSuperTypes(Class<?> cls, Class<?> endBefore, List<Class<?>> result)

public long
getSize(Object
the instance to write
value
,
Class<?>
the class of instance that is to be written.
type
,
Type
the type of instance to be written. jakarta.ws.rs.core.GenericEntity provides a way to specify this information at runtime.
genericType
,
Annotation[]
an array of the annotations attached to the message entity instance.
annotations
,
MediaType
the media type of the HTTP entity.
mediaType
)

Overrides default jakarta.ws.rs.ext.MessageBodyWriter.getSize.

Method that Jakarta-RS container calls to try to figure out serialized length of given value.

protected abstract boolean
hasMatchingMediaType(MediaType mediaType)

Helper method used to check whether given media type is supported by this provider.

protected boolean
hasMatchingMediaTypeForReading(MediaType mediaType)

Helper method used to check whether given media type is supported by this provider for read operations (when binding input data such as POST body).

protected boolean
hasMatchingMediaTypeForWriting(MediaType mediaType)

Helper method used to check whether given media type is supported by this provider for writing operations, such as when converting response object to response body of request (like GET or POST).

public boolean
public boolean
isReadable(Class<?>
the class of instance to be produced.
type
,
Type
the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned by Method.getGenericParameterTypes.
genericType
,
Annotation[]
an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by Method.getParameterAnnotations.
annotations
,
MediaType
the media type of the HTTP entity, if one is not specified in the request then application/octet-stream is used.
mediaType
)

Implements jakarta.ws.rs.ext.MessageBodyReader.isReadable.

Method that Jakarta-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider.

public boolean
isWriteable(Class<?>
the class of instance that is to be written.
type
,
Type
the type of instance to be written, obtained either by reflection of a resource method return type or via inspection of the returned instance. jakarta.ws.rs.core.GenericEntity provides a way to specify this information at runtime.
genericType
,
Annotation[]
an array of the annotations attached to the message entity instance.
annotations
,
MediaType
the media type of the HTTP entity.
mediaType
)

Implements jakarta.ws.rs.ext.MessageBodyWriter.isWriteable.

Method that Jakarta-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.

public MAPPER
locateMapper(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
)

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

public Object
readFrom(Class<Object>
the type that is to be read from the entity stream.
type
,
Type
the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned by Method.getGenericParameterTypes.
genericType
,
Annotation[]
an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by Method.getParameterAnnotations.
annotations
,
MediaType
the media type of the HTTP entity.
mediaType
,
MultivaluedMap<String, String>
the read-only HTTP headers associated with HTTP entity.
httpHeaders
,
InputStream
the InputStream of the HTTP entity. The caller is responsible for ensuring that the input stream ends when the entity has been consumed. The implementation should not close the input stream.
entityStream
)

Implements jakarta.ws.rs.ext.MessageBodyReader.readFrom.

Method that Jakarta-RS container calls to deserialize given value.

public void
removeUntouchable(Class<?> type)

Method for removing definition of specified type as untouchable: usually only

public void
setAnnotationsToUse(Annotations[]
Ordered list of annotation sets to use; if null, default
annotationsToUse
)

Method for configuring which annotation sets to use (including none).

public THIS
setDefaultReadView(Class<?> view)

Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.

public THIS
setDefaultView(Class<?> view)

Method for specifying JSON View to use for reading and writing content when end point does not have explicit View annotations.

public THIS
setDefaultWriteView(Class<?> view)

Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.

public void
setMapper(MAPPER m)

Method that can be used to directly define ObjectMapper to use for serialization and deserialization; if null, will use the standard provider discovery from context instead.

public void
writeTo(Object
the instance to write.
value
,
Class<?>
the class of instance that is to be written.
type
,
Type
the type of instance to be written. jakarta.ws.rs.core.GenericEntity provides a way to specify this information at runtime.
genericType
,
Annotation[]
an array of the annotations attached to the message entity instance.
annotations
,
MediaType
the media type of the HTTP entity.
mediaType
,
MultivaluedMap<String, Object>
a mutable map of the HTTP message headers.
httpHeaders
,
OutputStream
the OutputStream for the HTTP entity. The implementation must not close the output stream.
entityStream
)

Implements jakarta.ws.rs.ext.MessageBodyWriter.writeTo.

Method that Jakarta-RS container calls to serialize given value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait