public final class SerializerRepository extends Object implements SerializerProvider
serializers
to
transfer to a new instance of a coordination
service
. A coordination service instance may be stopped if the
configuration changes; this class could be used to transfer registered
serializers avoiding a re-registration of clients' custom
serializers
.Constructor and Description |
---|
SerializerRepository()
Creates a serializer repository.
|
SerializerRepository(SerializerProvider defaultSerializerProvider)
Creates a serializer repository.
|
Modifier and Type | Method and Description |
---|---|
<T> Serializer<T> |
getSerializer(Class<T> subject)
Gets a
serializer for the given subject . |
<T> Serializer<T> |
getSerializer(String subjectClassName)
Gets a
serializer for the given subject . |
<T> void |
registerSerializer(Serializer<T> serializer,
Class<T> subject)
Registers a serializer.
|
<T> void |
unregisterSerializer(Class<T> subject)
Unregisters a serializer.
|
public SerializerRepository()
StandardSerializerProvider
is used to provide a default
serializer
for classes no serializer
has been registered to.
public SerializerRepository(SerializerProvider defaultSerializerProvider)
defaultSerializerProvider
- provides a default serializer
for classes no serializer
has
been registered topublic <T> Serializer<T> getSerializer(Class<T> subject) throws IllegalArgumentException
SerializerProvider
serializer
for the given subject
.getSerializer
in interface SerializerProvider
subject
- subject to get a serializer
forserializer
suitable to
serialize/deserialize the given subject
IllegalArgumentException
- if a serializer
is
not possible fot the given subject
public <T> Serializer<T> getSerializer(String subjectClassName) throws IllegalArgumentException, ClassNotFoundException
SerializerProvider
serializer
for the given subject
.getSerializer
in interface SerializerProvider
subjectClassName
- class name of the subject to get a
serializer
forserializer
suitable to
serialize/deserialize the given subjectIllegalArgumentException
- if a serializer
is
not possible fot the given subject
ClassNotFoundException
- if the class given by
subjectClassName
is not foundpublic <T> void registerSerializer(Serializer<T> serializer, Class<T> subject)
serializer
- serializersubject
- subject the serializer is associated topublic <T> void unregisterSerializer(Class<T> subject)
subject
- subject the serializer is associated toCopyright © 2015. All Rights Reserved.