Interface SerializationProvider
- All Superinterfaces:
Service
Service providing Serializer instances.
The CacheManager obtains an instance of this
Service prior to creating any Cache instances. Before creating each Cache
instance, the CacheManager calls the
createKeySerializer(Class, ClassLoader, ServiceConfiguration[]) and
createValueSerializer(Class, ClassLoader, ServiceConfiguration[]) methods to obtain
Serializer instances for the Cache, either through explicit configuration or from
CacheManager level configuration.
Some Cache configurations make serialization mandatory. If serialization is mandatory,
failure to return a Serializer from a SerializationProvider
results in a Cache initialization failure. For a Cache in which serialization
is not mandatory, failing to return a Serializer will not cause Cache initialization
failure.
-
Method Summary
Modifier and TypeMethodDescription<T> Serializer<T>createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?, ?>... configs) Creates a keySerializerwith the given parameters.<T> Serializer<T>createValueSerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?, ?>... configs) Creates a valueSerializerwith the given parameters.voidreleaseSerializer(Serializer<?> serializer) Releases the givenSerializerinstance.
-
Method Details
-
createKeySerializer
<T> Serializer<T> createKeySerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?, ?>... configs) throws UnsupportedTypeExceptionCreates a keySerializerwith the given parameters.- Type Parameters:
T- the type serialized to serialize to/from- Parameters:
clazz- the class of the type to serialize to/fromclassLoader- the classloader used to load classes during deserialization; may benullconfigs- theServiceConfigurationinstances available through theCacheManager- Returns:
- a
Serializerinstance, possiblynull - Throws:
UnsupportedTypeException- if a serializer cannot be created for the given type
-
createValueSerializer
<T> Serializer<T> createValueSerializer(Class<T> clazz, ClassLoader classLoader, ServiceConfiguration<?, ?>... configs) throws UnsupportedTypeExceptionCreates a valueSerializerwith the given parameters.- Type Parameters:
T- the type serialized to serialize to/from- Parameters:
clazz- the class of the type to serialize to/fromclassLoader- the classloader used to load classes during deserialization; may benullconfigs- theServiceConfigurationinstances available through theCacheManager- Returns:
- a
Serializerinstance, possiblynull - Throws:
UnsupportedTypeException- if a serializer cannot be created for the given type
-
releaseSerializer
Releases the givenSerializerinstance. If the serializer is obtained from aSerializationProviderand implementsCloseable, theclosemethod is invoked.- Parameters:
serializer- the serializer to be released- Throws:
Exception- when the release fails
-