java.lang.Object
tools.jackson.databind.cfg.SerializationContexts
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SerializationContexts.DefaultImpl
Factory/builder class that replaces Jackson 2.x concept of "blueprint" instance
of
SerializationContext. It will be constructed and configured during
ObjectMapper building phase, and will be called once per writeValue
call to construct actual stateful SerializationContext to use during
serialization.
Note that since this object has to be serializable (to allow JDK serialization of
mapper instances), SerializationContext need not be serializable any more.
- Since:
- 3.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SerializerCacheCache for doing type-to-value-serializer lookups.protected final SerializerFactoryFactory responsible for constructing standard serializers.protected final TokenStreamFactoryLow-levelTokenStreamFactorythat may be used for constructing embedded generators. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedSerializationContexts(TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache) -
Method Summary
Modifier and TypeMethodDescriptionintMethod that can be used to determine how many serializers this provider is caching currently (if it does caching: default implementation does) Exact count depends on what kind of serializers get cached; default implementation caches all serializers, including ones that are eagerly constructed (for optimal access speed)abstract SerializationContextExtcreateContext(SerializationConfig config, GeneratorSettings genSettings) Factory method for constructing context object for individualwriteValue()calls.voidMethod that will drop all serializers currently cached by this provider.protected abstract SerializationContextsforMapper(Object mapper, TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache) forMapper(Object mapper, SerializationConfig config, TokenStreamFactory tsf, SerializerFactory serializerFactory) Mutant factory method called when instance is actually created for use by mapper (as opposed to coming into existence during building, module registration).
-
Field Details
-
_streamFactory
Low-levelTokenStreamFactorythat may be used for constructing embedded generators. -
_serializerFactory
Factory responsible for constructing standard serializers. -
_cache
Cache for doing type-to-value-serializer lookups.
-
-
Constructor Details
-
SerializationContexts
protected SerializationContexts() -
SerializationContexts
protected SerializationContexts(TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache)
-
-
Method Details
-
forMapper
public SerializationContexts forMapper(Object mapper, SerializationConfig config, TokenStreamFactory tsf, SerializerFactory serializerFactory) Mutant factory method called when instance is actually created for use by mapper (as opposed to coming into existence during building, module registration). Necessary usually to initialize non-configuration state, such as caching. -
forMapper
protected abstract SerializationContexts forMapper(Object mapper, TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache) -
createContext
public abstract SerializationContextExt createContext(SerializationConfig config, GeneratorSettings genSettings) Factory method for constructing context object for individualwriteValue()calls. -
cachedSerializersCount
public int cachedSerializersCount()Method that can be used to determine how many serializers this provider is caching currently (if it does caching: default implementation does) Exact count depends on what kind of serializers get cached; default implementation caches all serializers, including ones that are eagerly constructed (for optimal access speed)The main use case for this method is to allow conditional flushing of serializer cache, if certain number of entries is reached.
-
flushCachedSerializers
public void flushCachedSerializers()Method that will drop all serializers currently cached by this provider. This can be used to remove memory usage (in case some serializers are only used once or so), or to force re-construction of serializers after configuration changes for mapper than owns the provider.
-