开发者

Serialization Proxy with XMLEncoder/Decoder

How can I implement a Serialization Proxy that can be used with a X开发者_如何学编程MLEncoder/Decoder? The classic one (the Bloch one, I mean) doesn't work...


I believe you need to set PersistenceDelegates for each Encoder instance. You can make some changes to properties using the usual bean mechanism of providing a BeanInfo.

If you look at the source you will see that there is a load of hardwired fudges for AWT and Swing beans. It really isn't nice - I suggest looking at something like JAXB.


The short answer is that you need to write a front-end that manages serialization. However, that will be painful, and may not give you what you want. The original Java serialization mechanism allowed objects to control their own serialization and deserialization, the XML implementation doesn't. As far as I can tell, XMLEncoder/XMLDecoder were meant for value objects alone.

If you describe what you're actually trying to accomplish, it's likely that someone can give you an alternative approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜