***********************************************************************************************************************
The process of converting system representation to network representation is called an marshalling.
The process of converting data from network representation to sysytem representation is called un marshalling.
************************************************************************************************************************
Serialization:
================
the process of seprating data from an object is called serialization.
or
-> The process of writing state of an object to a file is called Serialization.
-> But strictly speaking, it is a process of converting an object from java supported form to either file supprted form
or network supported form or database supported form is called Serialization.
-> By using FileOutputStream and ObjectOutputStream, we can achieve Serialization.
It is meant for default Serialization.
Here everything takes care by JVM and Programmer doesn't have any control.
In Serialization, total object will be serialized always & it is not possible to serialize part of the object.
Relatively performance is low.
Serialization is best choice if we want to save total objects to the file.
Serialization Interface doesn't contain any methods.
So it is called as Marker Interface.******
transient keyword will play role in Serialization.
Step to create the serialization:
-----------------------------
step1 create the serialized class and its object.
ex:- class employee inplements serializable{
int emp id=101;
String emp name=ram;
----
-----
}
step2 create fileOutput stream.
FileOutputStream fos=new fileoutputStream("abc.txt");
Step3 create object outputStream
for that we have to use the following constructor.
public objectoutputstream(FileOutPutStream fos)
ex: objectoutputStream oos=new objectoutputStream(fos);
step4 write serializable object in object outputstream:
we have to use this method for that.
public void writeobject(object obj)
ex: Employee emp=new employee();
oos.writeobject(emp);
Desirialization:
==================
The process of regenerating the object on the basis of data is called the deserialization.
Step to perform the des:
-------------------------------
step1 create fileInputStream.
ex: fileInputStream fis=new fileInputStream("abc.txt");
Step2 create objectInputStream:
to create objectInputStream we have to use the following constructor.
public objectInputStream(FileInputStream fis)
ex: objectInputStream ois=new objectInputStream(fis);
Step3 read des obj from objectInputStream:
for that we have to use the method.
public object readObject()
ex:
Employee emp=(Employee)ois.read object();
Externalization:
=================
It is meant for customized Serialization.
Here everything takes care by Programmer and JVM doesn't have any control.
In Externalization, based on our requirement we can save either total object or part of the object.
Relatively performance is high.
Externalization is best choice if we want to save part of the object to the file.
Externalization Interface contains 2 methods. 1. writeExternal(-) and 2. readExternal(-)
So it is not a Marker Interface.
transient keyword will not play any role in Externalization.
Marker Interface:
==================
-> Marker interface in Java is interfaces with no field or methods or in simple word empty interface in java is called marker interface.
-> Example of marker interface is Serializable, Clonnable and Remote interface.
-> It looks they are used to indicate something to compiler or JVM.
-> So if JVM sees a class is Serializable it done some special operation on it,
similar way if JVM sees one class is implement Clonnable it performs some operation to support cloning.
Same is true for RMI and Remote interface. So in short Marker interface indicate, signal or a command to Compiler or JVM.
-> After introduction of Annotation on Java5, Annotation is better choice than marker interface and JUnit is a perfect example of using Annotation.
-> In summary marker interface in Java is used to indicate something to compiler, JVM or any other tool but Annotation is better way of doing same thing.
The process of converting system representation to network representation is called an marshalling.
The process of converting data from network representation to sysytem representation is called un marshalling.
************************************************************************************************************************
Serialization:
================
the process of seprating data from an object is called serialization.
or
-> The process of writing state of an object to a file is called Serialization.
-> But strictly speaking, it is a process of converting an object from java supported form to either file supprted form
or network supported form or database supported form is called Serialization.
-> By using FileOutputStream and ObjectOutputStream, we can achieve Serialization.
It is meant for default Serialization.
Here everything takes care by JVM and Programmer doesn't have any control.
In Serialization, total object will be serialized always & it is not possible to serialize part of the object.
Relatively performance is low.
Serialization is best choice if we want to save total objects to the file.
Serialization Interface doesn't contain any methods.
So it is called as Marker Interface.******
transient keyword will play role in Serialization.
Step to create the serialization:
-----------------------------
step1 create the serialized class and its object.
ex:- class employee inplements serializable{
int emp id=101;
String emp name=ram;
----
-----
}
step2 create fileOutput stream.
FileOutputStream fos=new fileoutputStream("abc.txt");
Step3 create object outputStream
for that we have to use the following constructor.
public objectoutputstream(FileOutPutStream fos)
ex: objectoutputStream oos=new objectoutputStream(fos);
step4 write serializable object in object outputstream:
we have to use this method for that.
public void writeobject(object obj)
ex: Employee emp=new employee();
oos.writeobject(emp);
Desirialization:
==================
The process of regenerating the object on the basis of data is called the deserialization.
Step to perform the des:
-------------------------------
step1 create fileInputStream.
ex: fileInputStream fis=new fileInputStream("abc.txt");
Step2 create objectInputStream:
to create objectInputStream we have to use the following constructor.
public objectInputStream(FileInputStream fis)
ex: objectInputStream ois=new objectInputStream(fis);
Step3 read des obj from objectInputStream:
for that we have to use the method.
public object readObject()
ex:
Employee emp=(Employee)ois.read object();
Externalization:
=================
It is meant for customized Serialization.
Here everything takes care by Programmer and JVM doesn't have any control.
In Externalization, based on our requirement we can save either total object or part of the object.
Relatively performance is high.
Externalization is best choice if we want to save part of the object to the file.
Externalization Interface contains 2 methods. 1. writeExternal(-) and 2. readExternal(-)
So it is not a Marker Interface.
transient keyword will not play any role in Externalization.
Marker Interface:
==================
-> Marker interface in Java is interfaces with no field or methods or in simple word empty interface in java is called marker interface.
-> Example of marker interface is Serializable, Clonnable and Remote interface.
-> It looks they are used to indicate something to compiler or JVM.
-> So if JVM sees a class is Serializable it done some special operation on it,
similar way if JVM sees one class is implement Clonnable it performs some operation to support cloning.
Same is true for RMI and Remote interface. So in short Marker interface indicate, signal or a command to Compiler or JVM.
-> After introduction of Annotation on Java5, Annotation is better choice than marker interface and JUnit is a perfect example of using Annotation.
-> In summary marker interface in Java is used to indicate something to compiler, JVM or any other tool but Annotation is better way of doing same thing.
Comments
Post a Comment