- All Implemented Interfaces:
Serializable,tools.jackson.core.util.Snapshottable<SerializerCache>
Cache contains three kinds of entries, based on combination of class pair key. First class in key is for the type to serialize, and second one is type used for determining how to resolve value type. One (but not both) of entries can be null.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBy default, allow caching of up to 4000 serializer entries (for possibly up to 1000 types; but depending access patterns may be as few as half of that). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAndResolveNonTypedSerializer(Class<?> rawType, JavaType fullType, ValueSerializer<Object> ser, SerializationContext ctxt) Another alternative that will cover both access via raw type and matching fully resolved type, in one fell swoop.voidaddAndResolveNonTypedSerializer(Class<?> type, ValueSerializer<Object> ser, SerializationContext ctxt) voidaddAndResolveNonTypedSerializer(JavaType type, ValueSerializer<Object> ser, SerializationContext ctxt) voidaddTypedSerializer(Class<?> cls, ValueSerializer<Object> ser) voidaddTypedSerializer(JavaType type, ValueSerializer<Object> ser) Method called if none of lookups succeeded, and caller had to construct a serializer.voidflush()Method called by StdSerializationContext#flushCachedSerializers() to clear all cached serializersMethod that can be called to get a read-only instance populated from the most recent version of the shared lookup Map.protected Objectintsize()snapshot()typedValueSerializer(Class<?> cls) Method that checks if the shared (and hence, synchronized) lookup Map might have a typed serializer for given type.typedValueSerializer(JavaType type) Method that checks if the shared (and hence, synchronized) lookup Map might have a typed serializer for given type.untypedValueSerializer(Class<?> type) Method that checks if the shared (and hence, synchronized) lookup Map might have an untyped serializer for given type.Method that checks if the shared (and hence, synchronized) lookup Map might have an untyped serializer for given type.
-
Field Details
-
DEFAULT_MAX_CACHE_SIZE
public static final int DEFAULT_MAX_CACHE_SIZEBy default, allow caching of up to 4000 serializer entries (for possibly up to 1000 types; but depending access patterns may be as few as half of that).- See Also:
-
-
Constructor Details
-
SerializerCache
public SerializerCache() -
SerializerCache
public SerializerCache(int maxCached) - Since:
- 3.0
-
SerializerCache
-
SerializerCache
-
-
Method Details
-
readResolve
-
snapshot
- Specified by:
snapshotin interfacetools.jackson.core.util.Snapshottable<SerializerCache>
-
getReadOnlyLookupMap
Method that can be called to get a read-only instance populated from the most recent version of the shared lookup Map. -
size
public int size() -
untypedValueSerializer
Method that checks if the shared (and hence, synchronized) lookup Map might have an untyped serializer for given type.NOTE: Synchronized to prevent a race condition where a thread reads an unresolved serializer that was put into the shared map by another thread inside
addAndResolveNonTypedSerializer(java.lang.Class<?>, tools.jackson.databind.ValueSerializer<java.lang.Object>, tools.jackson.databind.SerializationContext)beforeresolve()completes. See [databind#5813]. -
untypedValueSerializer
Method that checks if the shared (and hence, synchronized) lookup Map might have an untyped serializer for given type.NOTE: Synchronized to prevent a race condition where a thread reads an unresolved serializer that was put into the shared map by another thread inside
addAndResolveNonTypedSerializer(java.lang.Class<?>, tools.jackson.databind.ValueSerializer<java.lang.Object>, tools.jackson.databind.SerializationContext)beforeresolve()completes. See [databind#5813]. -
typedValueSerializer
Method that checks if the shared (and hence, synchronized) lookup Map might have a typed serializer for given type. -
typedValueSerializer
Method that checks if the shared (and hence, synchronized) lookup Map might have a typed serializer for given type. -
addTypedSerializer
Method called if none of lookups succeeded, and caller had to construct a serializer. If so, we will update the shared lookup map so that it can be resolved via it next time. -
addTypedSerializer
-
addAndResolveNonTypedSerializer
public void addAndResolveNonTypedSerializer(Class<?> type, ValueSerializer<Object> ser, SerializationContext ctxt) -
addAndResolveNonTypedSerializer
public void addAndResolveNonTypedSerializer(JavaType type, ValueSerializer<Object> ser, SerializationContext ctxt) -
addAndResolveNonTypedSerializer
public void addAndResolveNonTypedSerializer(Class<?> rawType, JavaType fullType, ValueSerializer<Object> ser, SerializationContext ctxt) Another alternative that will cover both access via raw type and matching fully resolved type, in one fell swoop. -
flush
public void flush()Method called by StdSerializationContext#flushCachedSerializers() to clear all cached serializers
-