Serialization Configuration

The following are example serialization configurations.


      <data-serializable-factory factory-id="1001">

      <portable-factory factory-id="9001">
      <serializer type-class="Employee" class-name="com.EmployeeSerializer">


Config config = new Config();
SerializationConfig srzConfig = config.getSerializationConfig();
srzConfig.setPortableVersion( "2" ).setUseNativeByteOrder( true );
srzConfig.setAllowUnsafe( true ).setEnableCompression( true );
srzConfig.setCheckClassDefErrors( true );

GlobalSerializerConfig globSrzConfig = srzConfig.getGlobalSerializerConfig();
globSrzConfig.setClassName( "abc.Class" );

SerializerConfig serializerConfig = srzConfig.getSerializerConfig();
serializerConfig.setTypeClass( "Employee" )
                .setClassName( "com.EmployeeSerializer" );

Serialization configuration has the following elements.

  • portable-version: Defines versioning of the portable serialization. Portable version differentiates two of the same classes that have changes, such as adding/removing field or changing a type of a field.
  • use-native-byte-order: Set to true to use native byte order for the underlying platform.
  • byte-order: Defines the byte order that the serialization will use: BIG_ENDIAN or LITTLE_ENDIAN. The default value is BIG_ENDIAN.
  • enable-compression: Enables compression if default Java serialization is used.
  • enable-shared-object: Enables shared object if default Java serialization is used.
  • allow-unsafe: Set to true to allow unsafe to be used.
  • data-serializable-factory: The DataSerializableFactory class to be registered.
  • portable-factory: The PortableFactory class to be registered.
  • global-serializer: The global serializer class to be registered if no other serializer is applicable.
  • serializer: The class name of the serializer implementation.
  • check-class-def-errors: When set to true, the serialization system will check for class definitions error at start and will throw a Serialization Exception with an error definition.