• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why we need externalizable interface in java  RSS feed

 
babu jayaraman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I know the Concept of serliazation and externalization, apart from this concept i have one doubt about externalization,


1. we have option to control serlization using transient keyword then why we need of externalizable interface.I feel both are doing same work.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. But Externalizable is an old interface. It is retained to maintain compatibility with very old Java code. New code should rarely, if ever, need it.

Serializable, and the related serialisation concepts, are the way forward, for new code.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Externalizable has in any way become obsolete (of course, it has had only limited use from the beginning). transient merely controls whether a particular field is serialized or not, while implementing Externalizable allows complete customization of the serialization process. Although I've never had to use it, I don't see which new feature would have replaced it.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialisation can do everything Externalisation can do, can't it? There are numerous hooks into Serialisation, so you can make it do almost anything you like. For instance, you certainly can serialise transient fields - it's only default serialisation that doesn't do that.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Externalization is a hook into serialization -- it was introduced as part of the Serialization architecture; it's not any kind of an older API. It's what you use if you want to be 100% responsible for the bits written for a given class.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really?

OK. I learnt something. Not that I expect to find any uses for Externalizable...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!