01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.applicator;
05:
06: import com.tc.object.ClientObjectManager;
07: import com.tc.object.TCObject;
08: import com.tc.object.TraversedReferences;
09: import com.tc.object.dna.api.DNA;
10: import com.tc.object.dna.api.DNAWriter;
11: import com.tc.object.tx.optimistic.OptimisticTransactionManager;
12:
13: import java.io.IOException;
14: import java.util.Map;
15:
16: /**
17: * Applies a serialzed change to an object.
18: */
19: public interface ChangeApplicator {
20:
21: /**
22: * Reconstitute the state of an object from DNA.
23: * @param objectManager The client-side object manager
24: * @param tcObject The manager for the object
25: * @param dna The DNA, representing the state of the object
26: * @param pojo A new instance of the object to reconstitute - this object will be modified with the values from the DNA
27: */
28: public void hydrate(ClientObjectManager objectManager,
29: TCObject tcObject, DNA dna, Object pojo)
30: throws IOException, ClassNotFoundException;
31:
32: /**
33: * Write an object's state to DNA
34: * @param objectManager The client-side object manager
35: * @param tcObject The manager for the object
36: * @param writer The DNA writer for writing the DNA
37: * @param pojo The object to write to writer
38: */
39: public void dehydrate(ClientObjectManager objectManager,
40: TCObject tcObject, DNAWriter writer, Object pojo);
41:
42: /**
43: * Create a new copy of the source object in the dest object, replacing connected objects with a new or
44: * existing clone as necessary. New clones that are created are returned so they can be properly
45: * updated from their originals.
46: * @param source The source object
47: * @param dest The destination copy object
48: * @param visited A Map of already visited objects and their clones (key=obj, value=clone)
49: * @param objectManager Client-side object manager
50: * @param txManager Transaction manager
51: * @return Newly cloned objects, key=obj, value=clone
52: */
53: public Map connectedCopy(Object source, Object dest, Map visited,
54: ClientObjectManager objectManager,
55: OptimisticTransactionManager txManager);
56:
57: /**
58: * Traverse an object and find all object references within it.
59: * @param pojo The object instance
60: * @param addTo A collection of traversed references found
61: * @return The addTo collection
62: */
63: public TraversedReferences getPortableObjects(Object pojo,
64: TraversedReferences addTo);
65:
66: /**
67: * Instantiate a new instance of the object from DNA. May not be supported on all applicators.
68: * @param objectManager The client-side object manager
69: * @param dna The DNA for the new object
70: * @return The new instance
71: */
72: public Object getNewInstance(ClientObjectManager objectManager,
73: DNA dna) throws IOException, ClassNotFoundException;
74: }
|