• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Externa-what-able????  RSS feed

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain to me in English what the Externalizable interface does? I tried to read the specks, but it quickly devolved into techno-babble about objects, I/O and Serializations. All I can make out is that the object that implements the Externalizable interface only has its identity written to the serialization stream and not its state? Why would you want that? And even though "it is the responsibility of the class to save and restore the contents of its instances" how exactly is this achieved?
Thanks in advance
Dan
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply - I guess you write externalizable when you have an object which would implement serializable but have many class variables declared transient. So instead of writing transient all the time you just implement serializable and by implementing the required methods you tell the complier which are the variables you want to be serialized.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,
The Externalizable interface gives programmers complete control over the serialization process. In certain circumstances, a programmer might not want the java.io.serialization to control the serialization. When you implement Externalizable you are telling the JVM that you will handle the complete loading and serializing of your object. You have to define the following 2 methods:
readExternal and writeExternal
You would probably using the readOject and writeObject methods from the java.io.ObjectStream class. Then you would need to perform the extra overhead that you require in either direction (i.e., refilling transient items, etc.).
Regards,
Manfred.
 
Dan Temple
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, Thanks to both of you
Dan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!