use of com.hazelcast.nio.serialization.compact.CompactSerializer in project hazelcast by hazelcast.
the class CompactStreamSerializer method registerConfiguredNamedSerializers.
private void registerConfiguredNamedSerializers(CompactSerializationConfig compactSerializationConfig) {
Map<String, TriTuple<String, String, String>> namedRegistries = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
for (TriTuple<String, String, String> registry : namedRegistries.values()) {
String className = registry.element1;
String typeName = registry.element2;
String serializerClassName = registry.element3;
Class clazz;
try {
clazz = ClassLoaderUtil.loadClass(classLoader, className);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Cannot load the class " + className);
}
CompactSerializer serializer;
if (serializerClassName != null) {
try {
serializer = ClassLoaderUtil.newInstance(classLoader, serializerClassName);
} catch (Exception e) {
throw new IllegalArgumentException("Cannot create an instance of " + serializerClassName);
}
} else {
if (javaRecordSerializer.isRecord(clazz)) {
serializer = javaRecordSerializer;
} else {
serializer = reflectiveSerializer;
}
}
CompactSerializableRegistration registration = new CompactSerializableRegistration(clazz, typeName, serializer);
classToRegistrationMap.put(clazz, registration);
typeNameToRegistrationMap.put(typeName, registration);
}
}
Aggregations