XStream

Advanced XStream.ID_REFERENCES marshal Mode, using nice id's from the bean if getId method found

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.3.1
  • Component/s: None
  • Labels:
    None

Description

That would be a nice feature making an xstreamed XML, containing lots of referenced objects, more readable.
We want to use this for a sort of GUI configuration, which could also be changed by a developer.

Things like uniqueness of the id's must of course be garantied by the programmer..

Activity

Hide
Laurent Hoss added a comment -

An example from our config , where objects reference other objects, here an object which has an id=Tree_topics, which is referenced by that id , in another object:
<entitySetModel id="6">
<list id="7">
<admingui.clientconfig.model.entityset.EntitySetFromFreemind id="8">
<id>Tree_topics</id>
<name>Tree_topics.mm</name>
<freemindFile class="admingui.clientconfig.model.freemind.FreemindFilesManager$1" reference="4"></freemindFile>
</admingui.clientconfig.model.entityset.EntitySetFromFreemind>
..

<admingui.clientconfig.model.selector.Selector id="12">
<id>selector1</id>
<crossList class="linked-list" id="13">
<admingui.clientconfig.model.selector.EntitySetSelectorConfig id="14">
<entitySet class=".admingui.clientconfig.model.entityset.EntitySetFromFreemind" reference="Tree_topics"></entitySet>
..
</admingui.clientconfig.model.selector.EntitySetSelectorConfig>

For us (and probably some other folks) it would have several advantages to use that user-defineable ID as reference, instead of the number!

  • makes it possible to make the config human read- and understandable
  • config can even be modified manually, inserting new objects with unique id's which do not break the existing config, like with incremental ID numbering
  • also a lot nicer (and should be faster) than xpath references

Besides, first we had another crazy idea:

  • Wouldn't it rock if one could serialize an object graph to a spring XML config !?
    That is, the generated file should instantiate the same object graph, when loaded by a spring application context
    Could this be done with XStream ?
    I guess there are some issues making this idea illusional, but many of these could probably be handled.
    This would allow to have the whole config only in Spring format, and not a mixture like we currently have when the more data centric objects are serialized with XStream.

This would also help following user (we having the same problem):
http://www.nabble.com/Add-a-ConvertListener-to-XStream-td13806257.html#a13845506

following posting maybe relevant for the wished Advanced XStream.ID_REFERENCES marshall Mode:
http://www.nabble.com/(De)Serializing-to-more-files-and-keeping-references-between-objects-td12071710.html#a12071710

Show
Laurent Hoss added a comment - An example from our config , where objects reference other objects, here an object which has an id=Tree_topics, which is referenced by that id , in another object: <entitySetModel id="6"> <list id="7"> <admingui.clientconfig.model.entityset.EntitySetFromFreemind id="8"> <id>Tree_topics</id> <name>Tree_topics.mm</name> <freemindFile class="admingui.clientconfig.model.freemind.FreemindFilesManager$1" reference="4"></freemindFile> </admingui.clientconfig.model.entityset.EntitySetFromFreemind> .. <admingui.clientconfig.model.selector.Selector id="12"> <id>selector1</id> <crossList class="linked-list" id="13"> <admingui.clientconfig.model.selector.EntitySetSelectorConfig id="14"> <entitySet class=".admingui.clientconfig.model.entityset.EntitySetFromFreemind" reference="Tree_topics"></entitySet> .. </admingui.clientconfig.model.selector.EntitySetSelectorConfig> For us (and probably some other folks) it would have several advantages to use that user-defineable ID as reference, instead of the number!
  • makes it possible to make the config human read- and understandable
  • config can even be modified manually, inserting new objects with unique id's which do not break the existing config, like with incremental ID numbering
  • also a lot nicer (and should be faster) than xpath references
Besides, first we had another crazy idea:
  • Wouldn't it rock if one could serialize an object graph to a spring XML config !? That is, the generated file should instantiate the same object graph, when loaded by a spring application context Could this be done with XStream ? I guess there are some issues making this idea illusional, but many of these could probably be handled. This would allow to have the whole config only in Spring format, and not a mixture like we currently have when the more data centric objects are serialized with XStream.
This would also help following user (we having the same problem): http://www.nabble.com/Add-a-ConvertListener-to-XStream-td13806257.html#a13845506 following posting maybe relevant for the wished Advanced XStream.ID_REFERENCES marshall Mode: http://www.nabble.com/(De)Serializing-to-more-files-and-keeping-references-between-objects-td12071710.html#a12071710
Hide
Joerg Schaible added a comment -

This can be implemented now with the next version 1.3.1, see acceptance test BeanIDCircularReferenceTest as implementation example.

Show
Joerg Schaible added a comment - This can be implemented now with the next version 1.3.1, see acceptance test BeanIDCircularReferenceTest as implementation example.
Hide
Joerg Schaible added a comment -

Set correct fix version.

Show
Joerg Schaible added a comment - Set correct fix version.
Hide
Joerg Schaible added a comment -

Fixed for upcoming release.

Show
Joerg Schaible added a comment - Fixed for upcoming release.
Hide
Olav Loen added a comment -

References does not use the ID from the bean, but the generated ID.

Show
Olav Loen added a comment - References does not use the ID from the bean, but the generated ID.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: