Class SerializationConfig

java.lang.Object
com.hazelcast.config.SerializationConfig

public class SerializationConfig extends Object
Contains the serialization configuration of HazelcastInstance.
  • Constructor Details

    • SerializationConfig

      public SerializationConfig()
    • SerializationConfig

      public SerializationConfig(SerializationConfig serializationConfig)
  • Method Details

    • getGlobalSerializerConfig

      public GlobalSerializerConfig getGlobalSerializerConfig()
      Returns:
      the global serializer configuration
      See Also:
    • setGlobalSerializerConfig

      public SerializationConfig setGlobalSerializerConfig(GlobalSerializerConfig globalSerializerConfig)
      Parameters:
      globalSerializerConfig - configuration of serializer that will be used if no other serializer is applicable
      Returns:
      GlobalSerializerConfig
    • getSerializerConfigs

      public Collection<SerializerConfig> getSerializerConfigs()
      Returns:
      list of SerializerConfigs
    • addSerializerConfig

      public SerializationConfig addSerializerConfig(SerializerConfig serializerConfig)
      Parameters:
      serializerConfig - serializer configuration of a class type
      Returns:
      configured SerializerConfig for chaining
    • setSerializerConfigs

      public SerializationConfig setSerializerConfigs(Collection<SerializerConfig> serializerConfigs)
      Parameters:
      serializerConfigs - lists of serializer configs that will be registered
      Returns:
      configured SerializerConfig for chaining
    • getPortableVersion

      @Deprecated(since="5.4", forRemoval=true) public int getPortableVersion()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Portable version will be used to differentiate two versions of the same class that have changes on the class, like adding/removing a field or changing a type of a field.
      Returns:
      version of portable classes
    • setPortableVersion

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig setPortableVersion(int portableVersion)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      portableVersion - int value for the version of portable classes
      Returns:
      configured SerializerConfig for chaining
    • getDataSerializableFactoryClasses

      public Map<Integer,String> getDataSerializableFactoryClasses()
      Returns:
      map of factory ID and corresponding factory class names
      See Also:
    • setDataSerializableFactoryClasses

      public SerializationConfig setDataSerializableFactoryClasses(Map<Integer,String> dataSerializableFactoryClasses)
      Parameters:
      dataSerializableFactoryClasses - map of factory ID and corresponding factory class names
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addDataSerializableFactoryClass

      public SerializationConfig addDataSerializableFactoryClass(int factoryId, String dataSerializableFactoryClass)
      Parameters:
      factoryId - factory ID of dataSerializableFactory to be registered
      dataSerializableFactoryClass - name of dataSerializableFactory class to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addDataSerializableFactoryClass

      public SerializationConfig addDataSerializableFactoryClass(int factoryId, Class<? extends DataSerializableFactory> dataSerializableFactoryClass)
      Parameters:
      factoryId - factory ID of dataSerializableFactory to be registered
      dataSerializableFactoryClass - dataSerializableFactory class to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • getDataSerializableFactories

      public Map<Integer,DataSerializableFactory> getDataSerializableFactories()
      Returns:
      map of factory ID and corresponding dataSerializable factories
      See Also:
    • setDataSerializableFactories

      public SerializationConfig setDataSerializableFactories(Map<Integer,DataSerializableFactory> dataSerializableFactories)
      Parameters:
      dataSerializableFactories - map of factory ID and corresponding dataSerializable objects
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addDataSerializableFactory

      public SerializationConfig addDataSerializableFactory(int factoryId, DataSerializableFactory dataSerializableFactory)
      Parameters:
      factoryId - factory ID of DataSerializableFactory to be registered
      dataSerializableFactory - DataSerializableFactory object to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • getPortableFactoryClasses

      @Deprecated(since="5.4", forRemoval=true) public Map<Integer,String> getPortableFactoryClasses()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Returns:
      map of factory ID and corresponding portable factory names
      See Also:
    • setPortableFactoryClasses

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig setPortableFactoryClasses(Map<Integer,String> portableFactoryClasses)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      portableFactoryClasses - map of factory ID and corresponding factory class names
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addPortableFactoryClass

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig addPortableFactoryClass(int factoryId, Class<? extends PortableFactory> portableFactoryClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      factoryId - factory ID of portableFactory to be registered
      portableFactoryClass - portableFactory class to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addPortableFactoryClass

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig addPortableFactoryClass(int factoryId, String portableFactoryClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      factoryId - factory ID of portableFactory to be registered
      portableFactoryClass - name of the portableFactory class to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • getPortableFactories

      @Deprecated(since="5.4", forRemoval=true) public Map<Integer,PortableFactory> getPortableFactories()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Returns:
      map of factory ID and corresponding portable factories
      See Also:
    • setPortableFactories

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig setPortableFactories(Map<Integer,PortableFactory> portableFactories)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      portableFactories - map of factory ID and corresponding factory objects
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • addPortableFactory

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig addPortableFactory(int factoryId, PortableFactory portableFactory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      factoryId - factory ID of portableFactory to be registered
      portableFactory - portableFactory object to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • getClassDefinitions

      @Deprecated(since="5.4", forRemoval=true) public Set<ClassDefinition> getClassDefinitions()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Returns:
      registered class definitions of portable classes
      See Also:
    • addClassDefinition

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig addClassDefinition(ClassDefinition classDefinition)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      classDefinition - the class definition to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • setClassDefinitions

      @Deprecated(since="5.4", forRemoval=true) public SerializationConfig setClassDefinitions(Set<ClassDefinition> classDefinitions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0.
      Parameters:
      classDefinitions - set of class definitions to be registered
      Returns:
      configured SerializerConfig for chaining
      See Also:
    • isCheckClassDefErrors

      public boolean isCheckClassDefErrors()
      Default value is true (enabled). When enabled, serialization system will check for class definitions error at start and throw an Serialization Exception with error definition.
      Returns:
      true if enabled, false otherwise
    • setCheckClassDefErrors

      public SerializationConfig setCheckClassDefErrors(boolean checkClassDefErrors)
      When enabled, serialization system will check for class definitions error at start and throw an Serialization Exception with error definition.
      Parameters:
      checkClassDefErrors - set to false to disable
      Returns:
      configured SerializerConfig for chaining
    • isUseNativeByteOrder

      public boolean isUseNativeByteOrder()
      Returns:
      true if serialization is configured to use native byte order of the underlying platform
    • setUseNativeByteOrder

      public SerializationConfig setUseNativeByteOrder(boolean useNativeByteOrder)
      Parameters:
      useNativeByteOrder - set to true to use native byte order of the underlying platform
      Returns:
      configured SerializerConfig for chaining
    • getByteOrder

      public ByteOrder getByteOrder()
      Note that result of useNativeByteOrder is not reflected to return value of this method.
      Returns:
      configured byte order
    • setByteOrder

      public SerializationConfig setByteOrder(ByteOrder byteOrder)
      Note that configuring use native byte order as enabled will override the byte order set by this method.
      Parameters:
      byteOrder - that serialization will use
      Returns:
      configured SerializerConfig for chaining
    • isEnableCompression

      public boolean isEnableCompression()
      Enables compression when default java serialization is used.
      Returns:
      true if compression enabled
    • setEnableCompression

      public SerializationConfig setEnableCompression(boolean enableCompression)
      Enables compression when default java serialization is used.
      Parameters:
      enableCompression - set to true to enable compression
      Returns:
      configured SerializerConfig for chaining
    • isEnableSharedObject

      public boolean isEnableSharedObject()
      Enables shared object when default java serialization is used.

      Default value is true.

      Returns:
      true if enabled
    • setEnableSharedObject

      public SerializationConfig setEnableSharedObject(boolean enableSharedObject)
      Enables shared object when default java serialization is used.
      Parameters:
      enableSharedObject - set to false to disable
      Returns:
      configured SerializerConfig for chaining
    • isAllowUnsafe

      public boolean isAllowUnsafe()
      Unsafe, it is not public api of java. Use with caution!

      Default value is false.

      Returns:
      true if using unsafe is allowed, false otherwise
    • setAllowUnsafe

      public SerializationConfig setAllowUnsafe(boolean allowUnsafe)
      Unsafe, it is not public api of java. Use with caution!
      Parameters:
      allowUnsafe - set to true to allow usage of unsafe
      Returns:
      configured SerializerConfig for chaining
    • isAllowOverrideDefaultSerializers

      public boolean isAllowOverrideDefaultSerializers()
      Returns:
      true if default serializers may be overridden by custom serializers
      Since:
      4.2
    • setAllowOverrideDefaultSerializers

      public SerializationConfig setAllowOverrideDefaultSerializers(boolean allowOverrideDefaultSerializers)
      This configuration should be used cautiously.

      Default serializers are used heavily by the hazelcast internally. If any of the instance in the same cluster overrides a default serializer, all the members and clients in the same cluster must override it with the same serializer.

      This configuration is introduced specifically to support the following case:

      • There was a custom configuration by the user for a type
      • Hazelcast decided to add a default serializer for the same type in a future release

      To be able to support Rolling Upgrade from an old version to the new version, one needs to make sure of the backward compatibility of the serialization. As a solution, the user will set this property on the new version so that new instances will be able to override new default serializers with their existing custom serializers.

      Parameters:
      allowOverrideDefaultSerializers - value to set
      Returns:
      configured SerializerConfig for chaining
      Since:
      4.2
    • getJavaSerializationFilterConfig

      public JavaSerializationFilterConfig getJavaSerializationFilterConfig()
      Returns:
      the javaSerializationFilterConfig
    • setJavaSerializationFilterConfig

      public SerializationConfig setJavaSerializationFilterConfig(JavaSerializationFilterConfig javaSerializationFilterConfig)
      Allows to configure deserialization protection filter.
      Parameters:
      javaSerializationFilterConfig - the javaFilterConfig to set (may be null)
    • setCompactSerializationConfig

      public SerializationConfig setCompactSerializationConfig(@Nonnull CompactSerializationConfig compactSerializationConfig)
      Parameters:
      compactSerializationConfig - config for the compact serialization format
      Returns:
      configured SerializerConfig for chaining
      Since:
      5.2
    • getCompactSerializationConfig

      public CompactSerializationConfig getCompactSerializationConfig()
      Returns:
      compact serialization config
      Since:
      5.2
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object