Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Data that is transferred between processes, persisted in the database, or exported to file, must be serialized. implements its own serialization mechanism for input and output streams, where each object to be serialized is referred to as a Storable. The serialization also includes a version control mechanism where an object can populate itself differently depending on the version of the incoming stream.

In the DTK there is only one programmatic interface for handling object serialization. Classes for this are located in the package devkit.storable. However, depending on the target,  handles serialization in two different ways:

  • Plain streams

    Plain streams are used in a running system. As with regular Java serialization, it is imperative that each element is written and read in the exact same order. For performance reasons these stream types are used within a running system in interclient communication.

  • XML

    In XML streams, each element is associated with a user defined name tag. The tag is used to locate the value. XML streams are used for database persistence and when objects are exported to a file, imported into another  system and during upgrades. The XML stream provides the ability to make use of a supplied version number to be able to automatically upgrade a configuration in a running system.


An object to be serialized must implement the DRStorable interface. This interface contains two methods that serialize the object: readFrom and writeTo: The methods operate on a DRInputStream and DROutputStream respectively, where data of various types may be obtained or set using a name tag.

Note!

All storables that are to be persisted, in either the database or exported/imported in , must have names defined. Other storables may use null, however, it is encouraged to always use unique name tags.

The readFrom method is handed a version parameter. When storables are deserialized, this parameter may be used to detect if the input stream is of the same version as when it was serialized. If not, different actions may be taken to populate values correctly. Again, it is only on XML streams that this version number is set. Streams supplied from the  runtime system will always contain the constant LATEST_VERSION.


  • No labels