Externalization allows you to customize how serialization is done. By implementing externalization you are controlling what gets serialized ( and what doesnot ) as versus default serialization where all non-transient attributes get serialized. For "fat data" classes with a large number of attributes only a few of which needs to persisted, externalization will help you reduce the size of serialized stream and the time taken to serialize the object. But there will be an overhead involved because the runtime has to call your methods to read/write objects. This is all I can think of, nothing else comes to my mind in terms of performance benefits. Anyone??
------------------ Ajith Kallambella M. Sun Certified Programmer for the Java2 Platform.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
1. Further more if you are subclassing your externalizable class you will want to invoke your superclass's implementation. So this causes overhead while you subclass your externalizable class. 2. methods in externalizable interface are public. So any malicious program can invoke which results into lossing the prior serialized state.
Ajith wrote: "But there will be an overhead involved because the runtime has to call your methods to read/write objects." Serialization has huge overheads in having to paw through private stuff via the JVM that is normally unavailable, and also with all the reflection it uses. Externalization is a simple method call. There is no overhead to the calls to your methods, it normally works out faster. Perverse, but true. --Jack http://www.JavaPerformanceTuning.com/