Object initialization after deserialization like readResolve in Java

Jul 27, 2014 at 9:54 AM
Hi together,
is there a way to init some properties/objects after deserialization which are not serialisized during the serializing process. E.g. if a property is a thread, sql connection or a datetime which is normaly created within the constructor and depends on the other properties like username and password at a sql connection or the current day at a datetime object.

With this objects i can´t use the DefaultValue attribute. The java xml serialiszation lib xstream automatically calls the readResolve() method in this case if you implement it (How do I initialize a transient field at deserialization?)

Can I annotate a method with an attribute to call it automatically after the creation process?

Thank you.
Michael
Coordinator
Jul 28, 2014 at 12:15 PM
Hi,
I'm afraid this is not supported. I suggest implementing it as a method called in the constructor, or a certain property setter.