Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

DSF ID Loader

To be Reviewed By: October 8, 2021

Authors: Jens Deppe

Status: Draft | Discussion | Active | Dropped | Superseded

...

Solution

The proposed solution includes introducing a Service Loader interface - DSFIDLoader - which will allow DSFIDs to be automatically discovered and will be initialized as part of the static class initialization already existing in InternalDataSerializer .has 2 parts:

Currently, the DSFIDSerializer  interface exposes a registerDSFID(int dsfid, Class<?> dsfidClass) method. This method will be moved into a new interface ( DataSerializerFixedIdRegistrant ) and DSFIDSerialzer  will extend this interface:

Code Block
languagejava
titleDataSerializableFixedIdRegistry
interface DataSerializeableFixedIdRegistry {
  register(int id, Class<? extends DataSerializableFixedId> clazz);
}

This will reduce the API surface area required by the following new service provider interface which would perform the actual Fixed Id registration:


Code Block
languagejava
titleDSFIDLoader interfaceDataSerializableRegistrant
public interface DSFIDLoaderDataSerializeableFixedIdRegistrant {
  void registerDSFIDsregister(DSFIDSerializerDataSerializableFixedIdRegistry serializerregistry);
}


This SPI will be initialized as part of the static class initialization already existing in InternalDataSerializer .

In order to use this, a module will need to:

  • Include a provider configuration resource file: resources/META-INF/services/org.apache.geode.internal.serialization.DataSerializabledFixedIdRegistrant
  • This file will contain one or more fully qualified class names which implement the above interface

The result will be that DSFIDs will be registered and available when the core serialization framework is instantiated.

Error Conditions

Currently, an IllegalArgumentException  is thrown, during registration, if the given class does not have a zero-argument constructor. This should be expanded to also produce an IllegalArgumentException  if a registration is attempted for a previously registered ID will be added to the geode-serialization module.

Changes and Additions to Public Interfaces

...