What is the Serialization of Objects?


Performance and scalability: What is the Serialization of Objects?

  1. Hi to Java Community,

    Can you please tell some things about Serialization..
    And is it for what purpose we are using?

    Thanks in advance.
  2. Serialization of Objects mean to store the value of an object at any given point of time. For example when you use MS Paint to draw certain figures and save them, then you actually serialize the state of the object(figure) when saving.

    In Java too you have got 2D APIs for drawing certain figures which you can use to draw and to be able to persist the state of the figures drawn so that they can be retrieved later you can serialize them.

    In case of advanced Java programming, consider a situation where your application wants to communicate with a remote object and wants reference to that remote object. As long as objects are on the same virtual space, they can be passed by reference(default behavior) but in case when an object needs to be passed in a different virtual space, in such a scenario, objects needs to be passed by value because the remote later does not have any reference to the object. So to meet this situation, objects needs to be serialized. While serializing, the parameters are marshalled and demarshalled on deserialization.

    To implement serialization, you need to implement the java.io.Serializable interface. It is just a marker interface which is understood by JVM and contains no methods. In case if you want an attribute of the object not to be serialized, then make it transient.

    You can get more clear picture of serialization from
    Mastering EJB by Ed Roman. He has considered good examples and scenarios to make the things clear. You can get a free copy of the book from theserverside.com
  3. Thanks!!
    ~ Sivanand.
  4. To serialize a object means to save the state of the object, prequisite is the state has not to be transient i.e. the resource which are O.S. and it is per process.
  5. Java serialization is in general quite an expensive operation, mostly because of the large amount of Java reflection and a rather inefficient generalized serialization method that leads to a large output byte array. GemFire from GemStone offers a highly optimzed serialization technology that: 1. Completely avoids the need for Java reflection by registering your class with our distributed system serialization manager. 2. Providing a DataSerializer with helper methods that serialize the members of your class instance with an average of about 75% fewer bytes (fow objects with huge fields, there is less of an adavantage. Taken together, this provides a very large boost in performance--both freeinng up your CPU to perform other tasks and optimizing network utilization. The API needed to take advantage of these capabilities is very simple (basically a Map with extra attributes for tuning and distribution). For serialization-intensive applications, this is definitely worth taking a look at! Cheers, Gideon gideon dot low at gemstone dot com GemFire-The Enterprise Data Fabric http://www.gemstone.com/downloads
  6. Hi, Serialization is nothing but flattening the Object so that you can store it any where or you can send it over the network. I think this would help you. http://java.sun.com/docs/books/tutorial/essential/io/serialization.html Please go through it for more information. Thank you.