com.microsoft.tfs.core.persistence
Interface MergeHandler


public interface MergeHandler

Monitors serialization and deserialization by PersistenceStore for update conflict events, and handles the conflicts when they are detected.

A MergeHandler is given modification stamps (long integers) that increment by at least 1 every time an object is modified (modification times on filesystems may be given). Filesystem implementations could use the modification time (in milliseconds).

See Also:
PersistenceStore
Since:
TEE-SDK-10.1
Thread-safety:
thread-compatible

Method Summary
 java.lang.Object merge(java.lang.Object storedObject, java.lang.Object latestObject)
          Invoked by PersistenceStore when a write conflict is detected to merge the two objects into a new object that will be stored.
 boolean needsMerge(java.lang.String itemName, long modificationStamp)
          Tests whether the given item needs merged with the item in storage that has the given modificationStamp.
 void updateModificationStampAfterRetrieve(java.lang.String itemName, long modificationStamp)
          Updates the handler's modification stamp for the item immediately after the it was read from storage.
 void updateModificationStampAfterStore(java.lang.String itemName, long modificationStamp)
          Updates the handler's modification stamp for the item immediately after it was saved to storage.
 

Method Detail

updateModificationStampAfterStore

void updateModificationStampAfterStore(java.lang.String itemName,
                                       long modificationStamp)
Updates the handler's modification stamp for the item immediately after it was saved to storage.

Parameters:
itemName - the name of the item just written (must not be null or empty)
modificationStamp - the modification number of the object after it was just written

updateModificationStampAfterRetrieve

void updateModificationStampAfterRetrieve(java.lang.String itemName,
                                          long modificationStamp)
Updates the handler's modification stamp for the item immediately after the it was read from storage.

Parameters:
itemName - the name of the item just read (must not be null or empty)
modificationStamp - the modification number of the object after it was just read

needsMerge

boolean needsMerge(java.lang.String itemName,
                   long modificationStamp)
Tests whether the given item needs merged with the item in storage that has the given modificationStamp.

Parameters:
itemName - the name of the item being tested (must not be null or empty)
modificationStamp - the modification number of the object after it exists in storage now (before it is read)
Returns:
true if the file needs merged, false if it does not.

merge

java.lang.Object merge(java.lang.Object storedObject,
                       java.lang.Object latestObject)
Invoked by PersistenceStore when a write conflict is detected to merge the two objects into a new object that will be stored. An implementation is free to return one of the given objects, or to return a new object.

Parameters:
storedObject - the object currently in storage (must not be null)
latestObject - the latest object not yet stored (must not be null)
Returns:
the object that will be saved.


© 2015 Microsoft. All rights reserved.