Hi everyone! How can I implement a Serialization Proxy that can be used with a XMLEncoder/Decoder? The classic one (the Bloch one, I mean) doesn't work...
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.
I believe you need to set PersistenceDelegate
s 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.