public interface SerializationProvider extends 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.
| Modifier and Type | Method and Description |
|---|---|
<T> Serializer<T> |
createKeySerializer(java.lang.Class<T> clazz,
java.lang.ClassLoader classLoader,
ServiceConfiguration<?,?>... configs)
Creates a key
Serializer with the given parameters. |
<T> Serializer<T> |
createValueSerializer(java.lang.Class<T> clazz,
java.lang.ClassLoader classLoader,
ServiceConfiguration<?,?>... configs)
Creates a value
Serializer with the given parameters. |
void |
releaseSerializer(Serializer<?> serializer)
Releases the given
Serializer instance. |
<T> Serializer<T> createKeySerializer(java.lang.Class<T> clazz, java.lang.ClassLoader classLoader, ServiceConfiguration<?,?>... configs) throws UnsupportedTypeException
Serializer with the given parameters.T - the type serialized to serialize to/fromclazz - the class of the type to serialize to/fromclassLoader - the classloader used to load classes during deserialization; may be nullconfigs - the ServiceConfiguration instances available through the
CacheManagerSerializer instance, possibly nullUnsupportedTypeException - if a serializer cannot be created for the given type<T> Serializer<T> createValueSerializer(java.lang.Class<T> clazz, java.lang.ClassLoader classLoader, ServiceConfiguration<?,?>... configs) throws UnsupportedTypeException
Serializer with the given parameters.T - the type serialized to serialize to/fromclazz - the class of the type to serialize to/fromclassLoader - the classloader used to load classes during deserialization; may be nullconfigs - the ServiceConfiguration instances available through the
CacheManagerSerializer instance, possibly nullUnsupportedTypeException - if a serializer cannot be created for the given typevoid releaseSerializer(Serializer<?> serializer) throws java.lang.Exception
Serializer instance.
If the serializer is obtained from a SerializationProvider and implements
Closeable, the close method is invoked.serializer - the serializer to be releasedjava.lang.Exception - when the release fails