ISlotFactory

The SlotFactory creates slots for use in Records in Messages. It is expandable with custom slot types.

The SlotFactory can be fetched as a service via the ServiceRegistry:

final ISlotFactory slotFactory = CServiceRegistry.getInstance()
                                                 .getService(ISlotFactory.class);

Creation of a slot

To create a slot we need the slot type:

ISlot create(CSlotType aType) throws CException;

The slot type can also be determined by the system by specifying a value:

ISlot fromObject(@Nullable Object aValue);

If you want to be on the safe side, you can also specify both:

ISlot fromObject(CSlotType aType,
                 Object aValue) throws CException;

Slot I/O with Data Streams

Slots can certainly be written to streams and read from streams.

@Nullable ISlot fromStream(@NotNull DataInput aStream) throws IOException;
void toStream(@NotNull DataOutput aStream,
              @NotNull ISlot aSlot) throws IOException;

For using JSON based transport protocol there is also a method for reading a slot from JSON. The methods for writing to a JSON format are included in the slot classes. The method is intended for internal use by the system. See also here.

@Nullable ISlot fromJson(@NotNull CSlotType aSlotType,
                         @NotNull Object aValue,
                         @NotNull Map<Integer, byte[]> aByteArrayStore);

Slot types

Since a slot type is represented by the class CSlotType, there are also methods to get the instance of this class:

CSlotType getSlotTypeByName(@NotNull String aName);
CSlotType getSlotTypeByOrdinal(int aOrdinal);

Registration of custom slot types

User-defined slot types can be registered. These can of course only be transported to other nodes, if they are used in all own nodes.

The registration takes place via:

void registerFactory(@NotNull CSlotType aType,
                     @NotNull ISingleSlotTypeFactory aFactory);

The factory can be uninstalled via:

void deregisterFactory(@NotNull CSlotType aType,
                       @NotNull ISingleSlotTypeFactory aFactory);
void deregisterFactory(@NotNull CSlotType aType);

nyssr.net - Innovative Distributed System