General

What is cedarsoft Serialization?

cedarsoft Serialization is *not* yet another serialization framework.

But it contains several classes that help you to write your own serializers very easily.

The key advantage is, that serializers written based on the abstract classes provided by cedarsoft Serialization support versioning very easily.

          <?xml version="1.0" encoding="UTF-8"?>
<businessObject xmlns="http://yourcompany.com/path/2.0.1">
  <name>theName</name>
  ...
</businessObject>
       

What does "versioning support" mean?

In some cases serialized objects only live for a few milli seconds (e.g. when using a WebService). But in other cases those objects live much longer (years and longer). And those serialized objects will live longer than your current application version.

Therefore it is necessary to make some good decisions to ensure that newer version of an application still support old version of serialized objects. Remember: Their data is one of the key assets for your users/customers.

cedarsoft Serialization offers base and support classes that enables you to write fast and powerful serializers that support old versions of your serialized objects properly.


Is only XML supported?

No.

cedarsoft Serialization basically consists of some classes that are build on some very basic principles. Those principles are valid for all kinds of serialization mechanism.

To make work easier, cedarsoft Serialization contains abstract base classes for serializers creating XML (using Stax).

If you prefer other XML parser or a completely different approach (e.g. binary) this is possible easily. You have just to implement some base classes for your serialization method. Further explanations can be foundhere.


What is the license for this project?

GPLv3 with Classpath Exception


Can I use cedarsoft Serialization for my project?

Yes

The Classpath Exception allows you to use cedarsoft Serialization with every project (every license).


Where can I get the source code from?

The source code is available from the Git repository at http://github.com/jschneider/com.cedarsoft.serialization.

To checkout the sources use

git clone git://github.com/jschneider/com.cedarsoft.serialization.git

Installation

How do I install cedarsoft Serialization?

It is recommended to use Maven. Then you just have to add a dependency. Details are explainedhere.

If you prefer downloading the necessary jars on your own, take a look athere.

Versioning

The framework will always serialize all the elements on the latest version of the serializers? Why?

Yes. Serialization always uses the newest version available.

And there are reasons for:

  • When writing old versions is supported, you should probably support *all* old versions. And that might become very complex.

  • When you create a new version there is a reason for that decision ("the old format is no longer good enough"). Therefore still writing the old format seems to be a bad idea.

  • It is probably not possible to map a new object to an old version format (e.g. added/changed properties).

    That is more problematic when writing, because you will loose information! When reading an old format, that won't happen information, instead default values can be used...

So in summary: Writing the old format seems to be unnecessary (or even worse: wrong) for by far the most cases.

Of course implementing that functionality is quite easy. So if really necessary, it can be done.

XML based serialization

How is the version information stored within the serialized file?

The default implementation (XML based on Stax) stores the version information as XML namespace declaration.

This is the recommended way for XML files. But of course it is possible to store that information in different ways. This is completely up to you. Just override the corresponding methods.


Why is the Stax backend recommended? ${your.preferred.parser} is much better!!!

No it is not.

Stax is the (new) standard pull parser interface contained in the JDK (since version 6). And it is very, very fast while providing a good API (that is the "pull" part)

But if you really prefer another XML parser - no problem. You just have to implement some abstract base classes (explained here). If you want to contribute your backend, send a message to themailing list.