Changes between Initial Version and Version 1 of uka.transport/DeepClone


Ignore:
Timestamp:
08/22/05 09:11:34 (8 years ago)
Author:
hauma
Comment:

From legacy page.

Legend:

Unmodified
Added
Removed
Modified
  • uka.transport/DeepClone

    v1 v1  
     1= Implementing methods for deep object cloning = 
     2 
     3[[TracNav]] 
     4In a transparent local invocation on a remote object it is necessary to create deep clones of the objects passed as arguments. A deep clone of an object is identical to the result of a consecutive marshal/unmarshal operation on that object. Since it is extremely inefficient deeply clone an object by marshaling it into a memory buffer and reading it back, the uka.transport serialization also provides a facility for fast deep object cloning. 
     5 
     6The following example shows how to implement the deep cloning part of interface Transportable. Please note that the methods shown below don't have to care about fields of basic type. Because they are based on the cloning mechanism provided by the regular Java API, these fields are already initialized correctly: 
     7 
     8{{{ 
     9#!java 
     10// 
     11// Deep clone: Methods and declarations for class TParam 
     12// 
     13public final Object deepClone(uka.transport.DeepClone _helper) 
     14    throws CloneNotSupportedException 
     15{ 
     16    Object _copy = clone(); 
     17    _helper.add(this, _copy); 
     18    ((TParam) _copy).deepCloneReferences(_helper); 
     19    return _copy; 
     20} 
     21 
     22protected void deepCloneReferences(uka.transport.DeepClone _helper) 
     23    throws CloneNotSupportedException 
     24{ 
     25    this.objectReference =  
     26       (java.lang.Object) _helper.doDeepClone(this.objectReference); 
     27} 
     28}}}