initializing transient fields
1 posts in topic
Flat View  Flat View

Posted By:   Amir_Pashazadeh
Posted On:   Saturday, June 26, 2004 02:05 AM


Is there a way to set values for transient fields after deserialization?

I have following code:

import org.apache.log4j.Logger;

public class MyDto implements Serializable {
transient protected final Logger logger = Logger.getLogger(this.getClass);



and the class has some other properties. When the class is deserialized the logger field will be null . How can initialize the logger after deserialization?

Re: initializing transient fields

Posted By:   Sean_Owen  
Posted On:   Monday, June 28, 2004 07:09 AM

Place a method like this in your class:

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
// restore transient fields here
About | Sitemap | Contact