I have read about Serialization theory part , where it says it is required when an object state need to be persisted . I have written a Web Service Application , Where it will run on different JVMs
I am in the process of improving the performance of my Web Service so I have decided to use transient
keyword for some of my Variables inside my Webservice
class
I have some questions related to it as what object need to be serialized and what should not be
1.First to start with for my Logger , I will use the keyword transient
For example :
private transient static final Logger logger = Logger.getLogger(Tata.class);
2.But what about the instance variables inside the class ?? do we need to use transient for them or not ?? For example :
String strategyData = null;
String errorText = null;
Properties prop = null;
Please share your inputs .
if the variable is declared as transient, then it will not be persisted. It is the main purpose of the transient keyword.
so all those variables which you do not need to store in the persisted state of the object can be declared as transient.
refer http://www.javabeat.net/tips/168-what-is-transient-keyword-in-java.html for more details