Search in sources :

Example 6 with CompactSerializer

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);
    }
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializer(com.hazelcast.nio.serialization.compact.CompactSerializer) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) IOException(java.io.IOException)

Aggregations

CompactSerializer (com.hazelcast.nio.serialization.compact.CompactSerializer)6 TriTuple (com.hazelcast.internal.util.TriTuple)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 EmployeeDTOSerializer (example.serialization.EmployeeDTOSerializer)2 Map (java.util.Map)2 Test (org.junit.Test)2 CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)1 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)1 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)1 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)1 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)1 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)1 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)1 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)1 RealmConfig (com.hazelcast.config.security.RealmConfig)1 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)1 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)1 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)1 DynamicConfigXmlGenerator.classNameOrImplClass (com.hazelcast.internal.dynamicconfig.DynamicConfigXmlGenerator.classNameOrImplClass)1