Hi Linghua,

Linghua Wang wrote:

> Hi,
> 
> I know there are two approaches to alias fields - one is hardcode call
> XStream.aliasField() method, and another is using annotation. The object I
> attemp to convert to XML is go without annotation against fields since
> they are maintained by others. So i have to use aliasField() method, but I
> doubt if there are any fields change in the future for this object that
> will break my code. My question is that - is there any idea/mind already
> be adopted into Xsteam to deal with such issue?

XStream behaves like Java serialization: It writes the fields by 
introspection and respects some kind of configuration (e.g. the aliases). 
So, yes, your observation is right, when the field name changes, your XML is 
no longer compatible without a change on your side.

All you can do is to write a little test suite that compares the generated 
XML with one that has been created by a previous version. Then you will at 
least notice, that you have to change something.

Basically there's no generic way to handle all cases, every strategy depends 
on the use case. You might get more stability if you write custom converters 
(see the tutorial) for your types. Then your code might no longer compile, 
if method names have been changed, but you might silently miss the fact that 
a marshalled object might have a new property to save.

>  Appeciate your feedback.

You're welcome,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to