public class StdDeserializerProvider extends DeserializerProvider
DeserializerProvider
implementation.
Handles low-level caching (non-root) aspects of deserializer
handling; all construction details are delegated to configured
DeserializerFactory
instance that the provider owns.Modifier and Type | Class and Description |
---|---|
protected static class |
StdDeserializerProvider.WrappedDeserializer
Simple deserializer that will call configured type deserializer, passing
in configured data deserializer, and exposing it all as a simple
deserializer.
|
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<JavaType,JsonDeserializer<Object>> |
_cachedDeserializers
We will also cache some dynamically constructed deserializers;
specifically, ones that are expensive to construct.
|
protected DeserializerFactory |
_factory
Factory responsible for constructing actual deserializers, if not
one of pre-configured types.
|
protected HashMap<JavaType,JsonDeserializer<Object>> |
_incompleteDeserializers
During deserializer construction process we may need to keep track of partially
completed deserializers, to resolve cyclic dependencies.
|
protected RootNameLookup |
_rootNames |
Constructor and Description |
---|
StdDeserializerProvider()
Default constructor.
|
StdDeserializerProvider(DeserializerFactory f) |
Modifier and Type | Method and Description |
---|---|
protected JsonDeserializer<Object> |
_createAndCache2(DeserializationConfig config,
JavaType type,
BeanProperty property)
Method that handles actual construction (via factory) and caching (both
intermediate and eventual)
|
protected JsonDeserializer<Object> |
_createAndCacheValueDeserializer(DeserializationConfig config,
JavaType type,
BeanProperty property)
Method that will try to create a deserializer for given type,
and resolve and cache it if necessary
|
protected JsonDeserializer<Object> |
_createDeserializer(DeserializationConfig config,
JavaType type,
BeanProperty property) |
protected JsonDeserializer<Object> |
_findCachedDeserializer(JavaType type) |
protected KeyDeserializer |
_handleUnknownKeyDeserializer(JavaType type) |
protected JsonDeserializer<Object> |
_handleUnknownValueDeserializer(JavaType type) |
protected void |
_resolveDeserializer(DeserializationConfig config,
ResolvableDeserializer ser) |
int |
cachedDeserializersCount()
Method that can be used to determine how many deserializers this
provider is caching currently
(if it does caching: default implementation does)
Exact count depends on what kind of deserializers get cached;
default implementation caches only dynamically constructed deserializers,
but not eagerly constructed standard deserializers (which is different
from how serializer provider works).
|
SerializedString |
findExpectedRootName(DeserializationConfig config,
JavaType type)
Method that can be used to try find expected root name for given type
|
KeyDeserializer |
findKeyDeserializer(DeserializationConfig config,
JavaType type,
BeanProperty property)
Method called to get hold of a deserializer to use for deserializing
keys for
Map . |
JsonDeserializer<Object> |
findTypedValueDeserializer(DeserializationConfig config,
JavaType type,
BeanProperty property)
Method called to locate deserializer for given type, as well as matching
type deserializer (if one is needed); and if type deserializer is needed,
construct a "wrapped" deserializer that can extract and use type information
for calling actual deserializer.
|
JsonDeserializer<Object> |
findValueDeserializer(DeserializationConfig config,
JavaType propertyType,
BeanProperty property)
Method called to get hold of a deserializer for a value of given type;
or if no such deserializer can be found, a default handler (which
may do a best-effort generic serialization or just simply
throw an exception when invoked).
|
void |
flushCachedDeserializers()
Method that will drop all dynamically constructed deserializers (ones that
are counted as result value for
cachedDeserializersCount() ). |
boolean |
hasValueDeserializerFor(DeserializationConfig config,
JavaType type)
Method that can be called to find out whether a deserializer can
be found for given type
|
JavaType |
mapAbstractType(DeserializationConfig config,
JavaType type)
Method that can be called to try to resolve an abstract type
(interface, abstract class) into a concrete type, or at least
something "more concrete" (abstract class instead of interface).
|
DeserializerProvider |
withAbstractTypeResolver(AbstractTypeResolver resolver) |
DeserializerProvider |
withAdditionalDeserializers(Deserializers d)
Method that is to configure
DeserializerFactory that provider has
to use specified deserializer provider, with highest precedence (that is,
additional providers have higher precedence than default one or previously
added ones) |
DeserializerProvider |
withAdditionalKeyDeserializers(KeyDeserializers d) |
DeserializerProvider |
withDeserializerModifier(BeanDeserializerModifier modifier) |
StdDeserializerProvider |
withFactory(DeserializerFactory factory)
Method that sub-classes need to override, to ensure that fluent-factory
methods will produce proper sub-type.
|
DeserializerProvider |
withValueInstantiators(ValueInstantiators instantiators)
Method that will construct a new instance with specified additional value instantiators
(i.e.
|
protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _cachedDeserializers
Given that we don't expect much concurrency for additions (should very quickly converge to zero after startup), let's explicitly define a low concurrency setting.
protected final HashMap<JavaType,JsonDeserializer<Object>> _incompleteDeserializers
protected final RootNameLookup _rootNames
protected DeserializerFactory _factory
public StdDeserializerProvider()
new StdDeserializerProvider(BeanDeserializerFactory.instance);
public StdDeserializerProvider(DeserializerFactory f)
public DeserializerProvider withAdditionalDeserializers(Deserializers d)
DeserializerProvider
DeserializerFactory
that provider has
to use specified deserializer provider, with highest precedence (that is,
additional providers have higher precedence than default one or previously
added ones)withAdditionalDeserializers
in class DeserializerProvider
public DeserializerProvider withAdditionalKeyDeserializers(KeyDeserializers d)
withAdditionalKeyDeserializers
in class DeserializerProvider
public DeserializerProvider withDeserializerModifier(BeanDeserializerModifier modifier)
withDeserializerModifier
in class DeserializerProvider
public DeserializerProvider withAbstractTypeResolver(AbstractTypeResolver resolver)
withAbstractTypeResolver
in class DeserializerProvider
public DeserializerProvider withValueInstantiators(ValueInstantiators instantiators)
DeserializerProvider
withValueInstantiators
in class DeserializerProvider
public StdDeserializerProvider withFactory(DeserializerFactory factory)
DeserializerProvider
withFactory
in class DeserializerProvider
public JavaType mapAbstractType(DeserializationConfig config, JavaType type) throws JsonMappingException
DeserializerProvider
mapAbstractType
in class DeserializerProvider
JsonMappingException
public SerializedString findExpectedRootName(DeserializationConfig config, JavaType type) throws JsonMappingException
DeserializerProvider
findExpectedRootName
in class DeserializerProvider
JsonMappingException
public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig config, JavaType propertyType, BeanProperty property) throws JsonMappingException
DeserializerProvider
Note: this method is only called for value types; not for keys.
Key deserializers can be accessed using DeserializerProvider.findKeyDeserializer(org.codehaus.jackson.map.DeserializationConfig, org.codehaus.jackson.type.JavaType, org.codehaus.jackson.map.BeanProperty)
.
findValueDeserializer
in class DeserializerProvider
config
- Deserialization configurationpropertyType
- Declared type of the value to deserializer (obtained using
'setter' method signature and/or type annotationsproperty
- Object that represents accessor for property value; field,
setter method or constructor parameter.JsonMappingException
- if there are fatal problems with
accessing suitable deserializer; including that of not
finding any serializerpublic JsonDeserializer<Object> findTypedValueDeserializer(DeserializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
DeserializerProvider
Since this method is only called for root elements, no referral information is taken.
findTypedValueDeserializer
in class DeserializerProvider
JsonMappingException
public KeyDeserializer findKeyDeserializer(DeserializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
DeserializerProvider
Map
.findKeyDeserializer
in class DeserializerProvider
JsonMappingException
- if there are fatal problems with
accessing suitable key deserializer; including that of not
finding any serializerpublic boolean hasValueDeserializerFor(DeserializationConfig config, JavaType type)
hasValueDeserializerFor
in class DeserializerProvider
public int cachedDeserializersCount()
DeserializerProvider
The main use case for this method is to allow conditional flushing of deserializer cache, if certain number of entries is reached.
cachedDeserializersCount
in class DeserializerProvider
public void flushCachedDeserializers()
cachedDeserializersCount()
).
This can be used to remove memory usage (in case some deserializers are
only used once or so), or to force re-construction of deserializers after
configuration changes for mapper than owns the provider.flushCachedDeserializers
in class DeserializerProvider
protected JsonDeserializer<Object> _findCachedDeserializer(JavaType type)
protected JsonDeserializer<Object> _createAndCacheValueDeserializer(DeserializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
config
- Configurationtype
- Type of property to deserializerproperty
- Property (field, setter, ctor arg) to use deserializer forJsonMappingException
protected JsonDeserializer<Object> _createAndCache2(DeserializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
JsonMappingException
protected JsonDeserializer<Object> _createDeserializer(DeserializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
JsonMappingException
protected void _resolveDeserializer(DeserializationConfig config, ResolvableDeserializer ser) throws JsonMappingException
JsonMappingException
protected JsonDeserializer<Object> _handleUnknownValueDeserializer(JavaType type) throws JsonMappingException
JsonMappingException
protected KeyDeserializer _handleUnknownKeyDeserializer(JavaType type) throws JsonMappingException
JsonMappingException