Search in sources :

Example 1 with InputOutputFactory

use of com.hazelcast.internal.serialization.InputOutputFactory in project hazelcast by hazelcast.

the class DefaultSerializationServiceBuilder method build.

@Override
public InternalSerializationService build() {
    initVersions();
    if (config != null) {
        addConfigDataSerializableFactories(dataSerializableFactories, config, classLoader);
        addConfigPortableFactories(portableFactories, config, classLoader);
        classDefinitions.addAll(config.getClassDefinitions());
    }
    InputOutputFactory inputOutputFactory = createInputOutputFactory();
    InternalSerializationService ss = createSerializationService(inputOutputFactory);
    registerSerializerHooks(ss);
    if (config != null) {
        if (config.getGlobalSerializerConfig() != null) {
            GlobalSerializerConfig globalSerializerConfig = config.getGlobalSerializerConfig();
            Serializer serializer = globalSerializerConfig.getImplementation();
            if (serializer == null) {
                try {
                    serializer = ClassLoaderUtil.newInstance(classLoader, globalSerializerConfig.getClassName());
                } catch (Exception e) {
                    throw new HazelcastSerializationException(e);
                }
            }
            if (serializer instanceof HazelcastInstanceAware) {
                ((HazelcastInstanceAware) serializer).setHazelcastInstance(hazelcastInstance);
            }
            ((AbstractSerializationService) ss).registerGlobal(serializer, globalSerializerConfig.isOverrideJavaSerialization());
        }
    }
    return ss;
}
Also used : HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) InputOutputFactory(com.hazelcast.internal.serialization.InputOutputFactory) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) Serializer(com.hazelcast.nio.serialization.Serializer)

Aggregations

GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)1 HazelcastInstanceAware (com.hazelcast.core.HazelcastInstanceAware)1 InputOutputFactory (com.hazelcast.internal.serialization.InputOutputFactory)1 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)1 Serializer (com.hazelcast.nio.serialization.Serializer)1