Package com.fasterxml.jackson.jaxrs.base
Class ProviderBase<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>,MAPPER extends com.fasterxml.jackson.databind.ObjectMapper,EP_CONFIG extends EndpointConfigBase<EP_CONFIG>,MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG,MAPPER>>
- java.lang.Object
-
- com.fasterxml.jackson.jaxrs.base.ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>
-
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
,javax.ws.rs.ext.MessageBodyReader<java.lang.Object>
,javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>
- Direct Known Subclasses:
JacksonCBORProvider
,JacksonJsonProvider
,JacksonSmileProvider
,JacksonXMLProvider
,JacksonYAMLProvider
public abstract class ProviderBase<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>,MAPPER extends com.fasterxml.jackson.databind.ObjectMapper,EP_CONFIG extends EndpointConfigBase<EP_CONFIG>,MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG,MAPPER>> extends java.lang.Object implements javax.ws.rs.ext.MessageBodyReader<java.lang.Object>, javax.ws.rs.ext.MessageBodyWriter<java.lang.Object>, com.fasterxml.jackson.core.Versioned
-
-
Field Summary
Fields Modifier and Type Field 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 java.util.HashMap<ClassKey,java.lang.Boolean>
_cfgCustomUntouchables
Map that contains overrides to default list of untouchable types:true
meaning that entry is untouchable,false
that is is not.protected java.lang.Class<?>
_defaultReadView
View to use for reading if none defined for the end point.protected java.lang.Class<?>
_defaultWriteView
View to use for writing if none defined for the end point.protected int
_jaxRSFeatures
Feature flags set.protected MAPPER_CONFIG
_mapperConfig
Helper object used for encapsulating configuration aspects ofObjectMapper
protected com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG>
_readers
Cache for resolved endpoint configurations when reading JSON datastatic java.lang.Class<?>[]
_unreadableClasses
static java.util.HashSet<ClassKey>
_untouchables
static java.lang.Class<?>[]
_unwritableClasses
protected com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG>
_writers
Cache for resolved endpoint configurations when writing JSON dataprotected static java.lang.String
CLASS_NAME_NO_CONTENT_EXCEPTION
static java.lang.Class<?>[]
DEFAULT_UNREADABLES
These are classes that we never use for reading (never try to deserialize instances of these types).protected static java.util.HashSet<ClassKey>
DEFAULT_UNTOUCHABLES
Looks like we need to worry about accidental data binding for types we shouldn't be handling.static java.lang.Class<?>[]
DEFAULT_UNWRITABLES
These are classes that we never use for writing (never try to serialize instances of these types).static java.lang.String
HEADER_CONTENT_TYPE_OPTIONS
This header is useful on Windows, trying to deal with potential XSS attacks.protected static int
JAXRS_FEATURE_DEFAULTS
private NoContentExceptionSupplier
noContentExceptionSupplier
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProviderBase()
Deprecated.protected
ProviderBase(MAPPER_CONFIG mconfig)
protected
ProviderBase(MAPPER_CONFIG mconfig, com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG> readerCache, com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG> writerCache)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static void
_addSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore, java.util.Collection<java.lang.Class<?>> result, boolean addClassItself)
protected abstract EP_CONFIG
_configForReading(com.fasterxml.jackson.databind.ObjectReader reader, java.lang.annotation.Annotation[] annotations)
protected EP_CONFIG
_configForReading(MAPPER mapper, java.lang.annotation.Annotation[] annotations, java.lang.Class<?> defaultView)
protected abstract EP_CONFIG
_configForWriting(com.fasterxml.jackson.databind.ObjectWriter writer, java.lang.annotation.Annotation[] annotations)
protected EP_CONFIG
_configForWriting(MAPPER mapper, java.lang.annotation.Annotation[] annotations, java.lang.Class<?> defaultView)
protected static boolean
_containedIn(java.lang.Class<?> mainType, java.util.HashSet<ClassKey> set)
protected com.fasterxml.jackson.core.JsonGenerator
_createGenerator(com.fasterxml.jackson.databind.ObjectWriter writer, java.io.OutputStream rawStream, com.fasterxml.jackson.core.JsonEncoding enc)
Overridable helper method called to create aJsonGenerator
for writing contents into given rawOutputStream
.protected java.io.IOException
_createNoContentException()
private static NoContentExceptionSupplier
_createNoContentExceptionSupplier()
Since classjavax.ws.rs.core.NoContentException
only exists in JAX-RS 2.0, but we want to have 1.x compatibility, need to dynamically select exception supplierprotected com.fasterxml.jackson.core.JsonParser
_createParser(com.fasterxml.jackson.databind.ObjectReader reader, java.io.InputStream rawStream)
Overridable helper method called to create aJsonParser
for reading contents of given rawInputStream
.protected EP_CONFIG
_endpointForReading(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders)
Overridable helper method that will basically fetch representation of the endpoint that can be used to getObjectReader
to use for deserializing contentprotected EP_CONFIG
_endpointForWriting(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)
protected java.lang.Boolean
_findCustomUntouchable(java.lang.Class<?> mainType)
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(java.lang.Class<?> type)
Overridable helper method used to allow handling of somewhat special types for readingprotected abstract MAPPER
_locateMapperViaProvider(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)
Helper method that is called if no mapper has been explicitly configured.protected void
_modifyHeaders(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, EP_CONFIG endpoint)
Overridable method used for adding optional response headers before serializing response object.private THIS
_this()
void
addUntouchable(java.lang.Class<?> 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).void
checkCanDeserialize(boolean state)
Method for defining whether actual detection for existence of a deserializer for type should be done whenisReadable(java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
is called.void
checkCanSerialize(boolean state)
Method for defining whether actual detection for existence of a serializer for type should be done whenisWriteable(java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
is called.THIS
configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state)
THIS
configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state)
THIS
configure(com.fasterxml.jackson.databind.DeserializationFeature f, boolean state)
THIS
configure(com.fasterxml.jackson.databind.SerializationFeature f, boolean state)
THIS
configure(JaxRSFeature feature, boolean state)
THIS
disable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
THIS
disable(com.fasterxml.jackson.core.JsonParser.Feature f)
THIS
disable(com.fasterxml.jackson.databind.DeserializationFeature f)
THIS
disable(com.fasterxml.jackson.databind.SerializationFeature f)
THIS
disable(JaxRSFeature feature)
THIS
disable(JaxRSFeature first, JaxRSFeature... f2)
THIS
enable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
THIS
enable(com.fasterxml.jackson.core.JsonParser.Feature f)
THIS
enable(com.fasterxml.jackson.databind.DeserializationFeature f)
THIS
enable(com.fasterxml.jackson.databind.SerializationFeature f)
THIS
enable(JaxRSFeature feature)
THIS
enable(JaxRSFeature first, JaxRSFeature... f2)
protected com.fasterxml.jackson.core.JsonEncoding
findEncoding(javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)
Helper method to use for determining desired output encoding.protected static java.util.List<java.lang.Class<?>>
findSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore)
protected static java.util.List<java.lang.Class<?>>
findSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore, java.util.List<java.lang.Class<?>> result)
private static java.lang.ClassLoader
getClassLoader()
long
getSize(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to figure out serialized length of given value.protected abstract boolean
hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
Helper method used to check whether given media type is supported by this provider.protected boolean
hasMatchingMediaTypeForReading(javax.ws.rs.core.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(javax.ws.rs.core.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).boolean
isEnabled(JaxRSFeature f)
boolean
isReadable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider.boolean
isWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.MAPPER
locateMapper(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)
Method called to locateObjectMapper
to use for serialization and deserialization.java.lang.Object
readFrom(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders, java.io.InputStream entityStream)
Method that JAX-RS container calls to deserialize given value.void
removeUntouchable(java.lang.Class<?> type)
Method for removing definition of specified type as untouchable: usually onlyvoid
setAnnotationsToUse(Annotations[] annotationsToUse)
Method for configuring which annotation sets to use (including none).THIS
setDefaultReadView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.THIS
setDefaultView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading and writing content when end point does not have explicit View annotations.THIS
setDefaultWriteView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.void
setMapper(MAPPER m)
Method that can be used to directly defineObjectMapper
to use for serialization and deserialization; if null, will use the standard provider discovery from context instead.void
writeTo(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream)
Method that JAX-RS container calls to serialize given value.
-
-
-
Field Detail
-
HEADER_CONTENT_TYPE_OPTIONS
public static final java.lang.String HEADER_CONTENT_TYPE_OPTIONS
This header is useful on Windows, trying to deal with potential XSS attacks.- See Also:
- Constant Field Values
-
CLASS_NAME_NO_CONTENT_EXCEPTION
protected static final java.lang.String CLASS_NAME_NO_CONTENT_EXCEPTION
- See Also:
- Constant Field Values
-
noContentExceptionSupplier
private final NoContentExceptionSupplier noContentExceptionSupplier
-
DEFAULT_UNTOUCHABLES
protected static final java.util.HashSet<ClassKey> DEFAULT_UNTOUCHABLES
Looks like we need to worry about accidental data binding for types we shouldn't be handling. This is probably not a very good way to do it, but let's start by blacklisting things we are not to handle.(why ClassKey? since plain old Class has no hashCode() defined, lookups are painfully slow)
-
DEFAULT_UNREADABLES
public static final java.lang.Class<?>[] DEFAULT_UNREADABLES
These are classes that we never use for reading (never try to deserialize instances of these types).
-
DEFAULT_UNWRITABLES
public static final java.lang.Class<?>[] DEFAULT_UNWRITABLES
These are classes that we never use for writing (never try to serialize instances of these types).
-
JAXRS_FEATURE_DEFAULTS
protected static final int JAXRS_FEATURE_DEFAULTS
-
_mapperConfig
protected final MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG,MAPPER> _mapperConfig
Helper object used for encapsulating configuration aspects ofObjectMapper
-
_cfgCustomUntouchables
protected java.util.HashMap<ClassKey,java.lang.Boolean> _cfgCustomUntouchables
Map that contains overrides to default list of untouchable types:true
meaning that entry is untouchable,false
that is is not.
-
_cfgCheckCanSerialize
protected boolean _cfgCheckCanSerialize
Whether we want to actually check that Jackson has a serializer for given type. Since this should generally be the case (due to auto-discovery) and since the call to check availability can be bit expensive, defaults to false.
-
_cfgCheckCanDeserialize
protected boolean _cfgCheckCanDeserialize
Whether we want to actually check that Jackson has a deserializer for given type. Since this should generally be the case (due to auto-discovery) and since the call to check availability can be bit expensive, defaults to false.
-
_jaxRSFeatures
protected int _jaxRSFeatures
Feature flags set.- Since:
- 2.3
-
_defaultReadView
protected java.lang.Class<?> _defaultReadView
View to use for reading if none defined for the end point.
-
_defaultWriteView
protected java.lang.Class<?> _defaultWriteView
View to use for writing if none defined for the end point.
-
_untouchables
public static final java.util.HashSet<ClassKey> _untouchables
-
_unreadableClasses
public static final java.lang.Class<?>[] _unreadableClasses
-
_unwritableClasses
public static final java.lang.Class<?>[] _unwritableClasses
-
_readers
protected final com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG extends EndpointConfigBase<EP_CONFIG>> _readers
Cache for resolved endpoint configurations when reading JSON data
-
_writers
protected final com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG extends EndpointConfigBase<EP_CONFIG>> _writers
Cache for resolved endpoint configurations when writing JSON data
-
-
Constructor Detail
-
ProviderBase
protected ProviderBase(MAPPER_CONFIG mconfig)
-
ProviderBase
@Deprecated protected ProviderBase()
Deprecated.Constructor that is only added to resolve [jaxrs-providers#10]; problems with combination of RESTeasy and CDI. Should NOT be used by any code explicitly; only exists for proxy support.
-
ProviderBase
protected ProviderBase(MAPPER_CONFIG mconfig, com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG> readerCache, com.fasterxml.jackson.databind.util.LookupCache<AnnotationBundleKey,EP_CONFIG> writerCache)
- Since:
- 2.17
-
-
Method Detail
-
checkCanDeserialize
public void checkCanDeserialize(boolean state)
Method for defining whether actual detection for existence of a deserializer for type should be done whenisReadable(java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
is called.
-
checkCanSerialize
public void checkCanSerialize(boolean state)
Method for defining whether actual detection for existence of a serializer for type should be done whenisWriteable(java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
is called.
-
addUntouchable
public void addUntouchable(java.lang.Class<?> 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).- Parameters:
type
- 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
-
removeUntouchable
public void removeUntouchable(java.lang.Class<?> type)
Method for removing definition of specified type as untouchable: usually only- Since:
- 2.2
-
setAnnotationsToUse
public void setAnnotationsToUse(Annotations[] annotationsToUse)
Method for configuring which annotation sets to use (including none). Annotation sets are defined in order decreasing precedence; that is, first one has the priority over following ones.- Parameters:
annotationsToUse
- Ordered list of annotation sets to use; if null, default
-
setMapper
public void setMapper(MAPPER m)
Method that can be used to directly defineObjectMapper
to use for serialization and deserialization; if null, will use the standard provider discovery from context instead. Default setting is null.
-
setDefaultReadView
public THIS setDefaultReadView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.- Since:
- 2.3
-
setDefaultWriteView
public THIS setDefaultWriteView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading content when end point does not have explicit View annotations.- Since:
- 2.3
-
setDefaultView
public THIS setDefaultView(java.lang.Class<?> view)
Method for specifying JSON View to use for reading and writing content when end point does not have explicit View annotations. Functionally equivalent to:setDefaultReadView(view); setDefaultWriteView(view);
- Since:
- 2.3
-
configure
public THIS configure(JaxRSFeature feature, boolean state)
-
enable
public THIS enable(JaxRSFeature feature)
-
enable
public THIS enable(JaxRSFeature first, JaxRSFeature... f2)
-
disable
public THIS disable(JaxRSFeature feature)
-
disable
public THIS disable(JaxRSFeature first, JaxRSFeature... f2)
-
isEnabled
public boolean isEnabled(JaxRSFeature f)
-
configure
public THIS configure(com.fasterxml.jackson.databind.DeserializationFeature f, boolean state)
-
enable
public THIS enable(com.fasterxml.jackson.databind.DeserializationFeature f)
-
disable
public THIS disable(com.fasterxml.jackson.databind.DeserializationFeature f)
-
configure
public THIS configure(com.fasterxml.jackson.databind.SerializationFeature f, boolean state)
-
enable
public THIS enable(com.fasterxml.jackson.databind.SerializationFeature f)
-
disable
public THIS disable(com.fasterxml.jackson.databind.SerializationFeature f)
-
enable
public THIS enable(com.fasterxml.jackson.core.JsonParser.Feature f)
-
enable
public THIS enable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
-
disable
public THIS disable(com.fasterxml.jackson.core.JsonParser.Feature f)
-
disable
public THIS disable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
-
configure
public THIS configure(com.fasterxml.jackson.core.JsonParser.Feature f, boolean state)
-
configure
public THIS configure(com.fasterxml.jackson.core.JsonGenerator.Feature f, boolean state)
-
hasMatchingMediaTypeForReading
protected boolean hasMatchingMediaTypeForReading(javax.ws.rs.core.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).Default implementation simply calls
hasMatchingMediaType(javax.ws.rs.core.MediaType)
.- Since:
- 2.3
-
hasMatchingMediaTypeForWriting
protected boolean hasMatchingMediaTypeForWriting(javax.ws.rs.core.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).Default implementation simply calls
hasMatchingMediaType(javax.ws.rs.core.MediaType)
.- Since:
- 2.3
-
hasMatchingMediaType
protected abstract boolean hasMatchingMediaType(javax.ws.rs.core.MediaType mediaType)
Helper method used to check whether given media type is supported by this provider.- Since:
- 2.2
-
_locateMapperViaProvider
protected abstract MAPPER _locateMapperViaProvider(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)
Helper method that is called if no mapper has been explicitly configured.
-
_configForReading
protected EP_CONFIG _configForReading(MAPPER mapper, java.lang.annotation.Annotation[] annotations, java.lang.Class<?> defaultView)
-
_configForWriting
protected EP_CONFIG _configForWriting(MAPPER mapper, java.lang.annotation.Annotation[] annotations, java.lang.Class<?> defaultView)
-
_configForReading
protected abstract EP_CONFIG _configForReading(com.fasterxml.jackson.databind.ObjectReader reader, java.lang.annotation.Annotation[] annotations)
-
_configForWriting
protected abstract EP_CONFIG _configForWriting(com.fasterxml.jackson.databind.ObjectWriter writer, java.lang.annotation.Annotation[] annotations)
-
getSize
public long getSize(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to figure out serialized length of given value. Since computation of this length is about as expensive as serialization itself, implementation will return -1 to denote "not known", so that container will determine length from actual serialized output (if needed).- Specified by:
getSize
in interfacejavax.ws.rs.ext.MessageBodyWriter<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>>
-
isWriteable
public boolean isWriteable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether given value (of specified type) can be serialized by this provider. Implementation will first check that expected media type is expected one (by call tohasMatchingMediaType(javax.ws.rs.core.MediaType)
); then verify that type is not one of "untouchable" types (types we will never automatically handle), and finally that there is a serializer for type (iffcheckCanSerialize(boolean)
has been called with true argument -- otherwise assumption is there will be a handler)- Specified by:
isWriteable
in interfacejavax.ws.rs.ext.MessageBodyWriter<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>>
-
writeTo
public void writeTo(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream) throws java.io.IOException
Method that JAX-RS container calls to serialize given value.- Specified by:
writeTo
in interfacejavax.ws.rs.ext.MessageBodyWriter<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>>
- Throws:
java.io.IOException
-
findEncoding
protected com.fasterxml.jackson.core.JsonEncoding findEncoding(javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)
Helper method to use for determining desired output encoding. For now, will always just use UTF-8...
-
_modifyHeaders
protected void _modifyHeaders(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, EP_CONFIG endpoint) throws java.io.IOException
Overridable method used for adding optional response headers before serializing response object.- Throws:
java.io.IOException
-
_createGenerator
protected com.fasterxml.jackson.core.JsonGenerator _createGenerator(com.fasterxml.jackson.databind.ObjectWriter writer, java.io.OutputStream rawStream, com.fasterxml.jackson.core.JsonEncoding enc) throws java.io.IOException
Overridable helper method called to create aJsonGenerator
for writing contents into given rawOutputStream
.- Throws:
java.io.IOException
- Since:
- 2.3
-
_endpointForWriting
protected EP_CONFIG _endpointForWriting(java.lang.Object value, java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders)
-
isReadable
public boolean isReadable(java.lang.Class<?> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider. Implementation will first check that expected media type is a JSON type (via call tohasMatchingMediaType(javax.ws.rs.core.MediaType)
); then verify that type is not one of "untouchable" types (types we will never automatically handle), and finally that there is a deserializer for type (iffcheckCanDeserialize(boolean)
has been called with true argument -- otherwise assumption is there will be a handler)- Specified by:
isReadable
in interfacejavax.ws.rs.ext.MessageBodyReader<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>>
-
readFrom
public java.lang.Object readFrom(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders, java.io.InputStream entityStream) throws java.io.IOException
Method that JAX-RS container calls to deserialize given value.- Specified by:
readFrom
in interfacejavax.ws.rs.ext.MessageBodyReader<THIS extends ProviderBase<THIS,MAPPER,EP_CONFIG,MAPPER_CONFIG>>
- Throws:
java.io.IOException
-
_createParser
protected com.fasterxml.jackson.core.JsonParser _createParser(com.fasterxml.jackson.databind.ObjectReader reader, java.io.InputStream rawStream) throws java.io.IOException
Overridable helper method called to create aJsonParser
for reading contents of given rawInputStream
. May return null to indicate that Stream is empty; that is, contains no content.- Throws:
java.io.IOException
- Since:
- 2.2
-
_endpointForReading
protected EP_CONFIG _endpointForReading(java.lang.Class<java.lang.Object> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> httpHeaders)
Overridable helper method that will basically fetch representation of the endpoint that can be used to getObjectReader
to use for deserializing content- Since:
- 2.8
-
locateMapper
public MAPPER locateMapper(java.lang.Class<?> type, javax.ws.rs.core.MediaType mediaType)
Method called to locateObjectMapper
to use for serialization and deserialization. Exact logic depends on setting ofJaxRSFeature.DYNAMIC_OBJECT_MAPPER_LOOKUP
.If
JaxRSFeature.DYNAMIC_OBJECT_MAPPER_LOOKUP
is disabled (default setting unless changed), behavior is as follows:- If an instance has been explicitly defined by
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)
If
JaxRSFeature.DYNAMIC_OBJECT_MAPPER_LOOKUP
is enabled, steps 1 and 2 are reversed, such that JAX-RSContextResolver
is first used, and only if none is defined will configured mapper be used.- Parameters:
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 toContextResolver
as is.mediaType
- Declared media type for the instance to process: not used by this method, but will be passed toContextResolver
as is.
- If an instance has been explicitly defined by
-
_isSpecialReadable
protected boolean _isSpecialReadable(java.lang.Class<?> type)
Overridable helper method used to allow handling of somewhat special types for reading- Since:
- 2.2
-
_isIgnorableForReading
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.- Since:
- 2.6
-
_isIgnorableForWriting
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.- Since:
- 2.6
-
_createNoContentException
protected java.io.IOException _createNoContentException()
-
_containedIn
protected static boolean _containedIn(java.lang.Class<?> mainType, java.util.HashSet<ClassKey> set)
-
_findCustomUntouchable
protected java.lang.Boolean _findCustomUntouchable(java.lang.Class<?> mainType)
-
findSuperTypes
protected static java.util.List<java.lang.Class<?>> findSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore)
-
findSuperTypes
protected static java.util.List<java.lang.Class<?>> findSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore, java.util.List<java.lang.Class<?>> result)
-
_addSuperTypes
protected static void _addSuperTypes(java.lang.Class<?> cls, java.lang.Class<?> endBefore, java.util.Collection<java.lang.Class<?>> result, boolean addClassItself)
-
_this
private final THIS _this()
-
_createNoContentExceptionSupplier
private static NoContentExceptionSupplier _createNoContentExceptionSupplier()
Since classjavax.ws.rs.core.NoContentException
only exists in JAX-RS 2.0, but we want to have 1.x compatibility, need to dynamically select exception supplier
-
getClassLoader
private static java.lang.ClassLoader getClassLoader()
-
-