Serialization – Pitney Bowes MapXtreme User Manual

Page 511

Advertising
background image

Appendix D: Extensible Data Providers

Advanced Topics / Important Considerations

MapXtreme v7.1

518

Developer Guide

The write methods must create an XmlElement that is inserted into the workspace XML. The
elements are bound to an XML document instance, so the XmlDocument is provided along with the
extensible data provider definition interface to be persisted. Note, for the DataSourceDefinition write
method, the XmlDocument is provided directly as a method argument, whereas, for the
TableDefinition write method, the XmlDocument is provided via the Document member of the
IMxpPersistenceServices argument.

XmlElement outerTag = xmlDocument.CreateElement("sample",
"SampleTableDefinition", "http://sample/sample");
XmlElement innerTag = xmlDocument.CreateElement("sample", "TableName",
"http://sample/sample");
innerTag.InnerText = "test";
outerTag.AppendChild(elNode);

For additional information and examples, consult the Developer Reference Guide documentation,
the

SpatiaLite Sample Data Provider

, and other data provider examples located on the

MapXtreme Code Exchange

.

Serialization

Serialization is the process of converting an object into a stream of data in order to preserve it in a
permanent form or in memory for the duration of its usefulness. This process is an essential part of
maintaining objects in MapXtreme web applications and multi-threaded desktop applications.

Without serialization, objects would need to be recreated, for example, every time there was a web
request for that object during a session.

When a serialized object is requested, it is deserialized (or recreated from the stream of data) and
then modified. MapXtreme’s serialization algorithm does not make a copy of the object (as other
serialization algorithms do) such that the object being deserialized is created only once.

For proper state management of web applications and multi-threaded desktop applications,
application developers often need to serialize MapXtreme Table instances directly, or via
serialization of the MapXtreme Catalog which contains the collection of all tables. When a table type
is not supported, it places a burden on the application developer to figure out how to explicitly
manage those tables and the overall state of their Catalog to operate around this limitation. For that
reason, Extensible Data Provider developers are encouraged to support serialization of their
provider to properly integrate into MapXtreme's Table serialization workflow.

What components of my provider implementation do I have to serialize?

MapXtreme distinguishes tables as being either permanent or temporary. Permanent tables only
have to serialize their definition/structure in order to be properly re-constructed upon deserialization.
Temporary tables have the additional responsibility of serializing their data. Extensible Data Provider
tables are considered permanent tables thereby simplifying the overall serialization responsibilities,
although several provider classes must still be serialized.

For those providers supporting the concept of data sources, the classes implementing the
IDataSourceDefinition and IDataSource interfaces must both be serializable. Whether or not data
sources are supported, every provider must also support serialization of the classes implementing

Advertising