Sunday, November 2, 2008

what is a transient variable

Serialize means to keep the state of an object i.e when you serialize an object you actually capture the current state of object in binary form, then you can write it in FileOutputStream or can send it to Socket's OutputStream.
De-Serialize means to read that binary data from FileInputStream or Socket's InputStream and convert it in to original Object.
In Java WriteObject() and ReadObject() methods used for Serialize and De- Serialize.

Marshalling and UnMarshalling:
Marshalling means to send the data on wire and UnMarshalling means to get the data from wire.

Marshalling :marshals means to packup the information. The skeleton on the ser ver marshals the parameters and calls methods on remote object if any.
Un-Marshalling :un-marshals means to un-pack the information.The stub un-marshals the results and gives the results to the clients.

Transient variable,can not be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the value of the variable can not be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null

You use the transient keyword to indicate to the Java virtual machine that the indicated variable is not part of the persistent state of the object. Variables that are part of the persistent state of an object must be saved when the object is archived.

No comments: