public class MergeManager extends Object
Purpose: Used to manage the merge of two objects in a unit of work.
Modifier and Type | Field and Description |
---|---|
protected ArrayList |
acquiredLocks
Used to store the list of locks that this merge manager has acquired for this merge
|
static int |
CASCADE_ALL_PARTS |
static int |
CASCADE_BY_MAPPING |
static int |
CASCADE_PRIVATE_PARTS |
protected int |
cascadePolicy
Policy that determines how the merge will cascade to its object's parts.
|
protected static int |
CHANGES_INTO_DISTRIBUTED_CACHE |
protected static int |
CLONE_INTO_WORKING_COPY |
protected static int |
CLONE_WITH_REFS_INTO_WORKING_COPY |
protected boolean |
forceCascade
Force cascade merge even if a clone is already registered
|
static boolean |
LOCK_ON_MERGE |
protected IdentityHashtable |
mergedNewObjects
Used to keep track of merged new objects.
|
protected int |
mergePolicy
Policy that determines merge type (i.e.
|
static int |
NO_CASCADE |
protected IdentityHashtable |
objectDescriptors
Used only while refreshing objects on remote session
|
protected IdentityHashtable |
objectsAlreadyMerged
Used to unravel recursion.
|
protected static int |
ORIGINAL_INTO_WORKING_COPY |
protected LinkedNode |
queueNode
Stores the node that holds this mergemanager within the WriteLocksManager queue
|
protected static int |
REFRESH_REMOTE_OBJECT |
protected AbstractSession |
session
The unit of work merging for.
|
protected long |
systemTime |
protected static int |
WORKING_COPY_INTO_BACKUP |
protected static int |
WORKING_COPY_INTO_ORIGINAL |
protected static int |
WORKING_COPY_INTO_REMOTE |
protected CacheKey |
writeLockQueued
If this variable is not null then the mergemanager is waiting on a particular cacheKey
|
Constructor and Description |
---|
MergeManager(AbstractSession session) |
Modifier and Type | Method and Description |
---|---|
protected IdentityHashtable |
buildIdentitySet(Object container,
ContainerPolicy containerPolicy,
boolean keyByTarget)
Build and return an identity set for the specified container.
|
void |
cascadeAllParts()
Cascade all parts, this is the default for the merge.
|
void |
cascadePrivateParts()
Cascade private parts, this can be used to merge clone when using RMI.
|
void |
dontCascadeParts()
Merge only direct parts, this can be used to merge clone when using RMI.
|
ArrayList |
getAcquiredLocks() |
int |
getCascadePolicy() |
protected int |
getMergePolicy() |
IdentityHashtable |
getObjectDescriptors() |
IdentityHashtable |
getObjectsAlreadyMerged() |
Object |
getObjectToMerge(Object sourceValue) |
LinkedNode |
getQueueNode()
INTENRAL:
Used to get the node that this merge manager is stored in, within the WriteLocksManager write lockers queue
|
AbstractSession |
getSession() |
long |
getSystemTime()
Get the stored value of the current time.
|
Object |
getTargetVersionOfSourceObject(Object source)
Return the coresponding value that should be assigned to the target object for the source object.
|
CacheKey |
getWriteLockQueued()
INTENRAL:
Used to get the object that the merge manager is waiting on, in order to acquire locks
|
Object |
mergeChanges(Object object,
ObjectChangeSet objectChangeSet)
Recursively merge changes in the object dependent on the merge policy.
|
void |
mergeChangesFromChangeSet(UnitOfWorkChangeSet uowChangeSet)
INTERNAL:
Merge the changes to all objects to session's cache.
|
boolean |
mergeChangesInCollection(Object source,
Object target,
Object backup,
DatabaseMapping mapping)
Merge the changes from the collection of a source object into the target using the backup as the diff.
|
protected Object |
mergeChangesOfCloneIntoWorkingCopy(Object rmiClone)
Recursively merge to rmi clone into the unit of work working copy.
|
protected Object |
mergeChangesOfOriginalIntoWorkingCopy(Object clone)
Recursively merge to original from its parent into the clone.
|
protected Object |
mergeChangesOfWorkingCopyIntoOriginal(Object clone,
ObjectChangeSet objectChangeSet)
Recursively merge to clone into the orignal in its parent.
|
void |
mergeCloneIntoWorkingCopy()
This can be used by the user for merging clones from RMI into the unit of work.
|
void |
mergeCloneWithReferencesIntoWorkingCopy()
This is used during the merge of dependent objects referencing independent objects, where you want
the independent objects merged as well.
|
void |
mergeIntoDistributedCache()
This is used during cache synchronisation to merge the changes into the distributed cache.
|
Object |
mergeNewObjectIntoCache(ObjectChangeSet changeSet)
Merge a change set for a new object into the cache.
|
void |
mergeOriginalIntoWorkingCopy()
This is used to revert changes to objects, or during refreshes.
|
void |
mergeWorkingCopyIntoBackup()
This is used during the unit of work commit to merge changes into the parent.
|
void |
mergeWorkingCopyIntoOriginal()
This is used during the unit of work commit to merge changes into the parent.
|
void |
mergeWorkingCopyIntoRemote()
This is used during the unit of work commit to merge changes into the parent.
|
void |
refreshRemoteObject()
INTERNAL:
This is used to refresh remote session object
|
protected Object |
registerObjectForMergeCloneIntoWorkingCopy(Object clone)
INTERNAL:
When merging froma clone when the cache cannot be gaurenteed the object must be first read if it is existing
and not in the cache.
|
void |
registerRemovedNewObjectIfRequired(Object removedObject)
Determine if the object is a registered new object, and that this is a nested unit of work
merge into the parent.
|
void |
setCascadePolicy(int cascadePolicy) |
void |
setForceCascade(boolean forceCascade) |
protected void |
setMergePolicy(int mergePolicy) |
void |
setObjectDescriptors(IdentityHashtable objectDescriptors) |
protected void |
setObjectsAlreadyMerged(IdentityHashtable objectsAlreadyMerged) |
void |
setQueueNode(LinkedNode node)
INTENRAL:
Used to set the node that this merge manager is stored in, within the WriteLocksManager write lockers queue
|
protected void |
setSession(AbstractSession session) |
void |
setWriteLockQueued(CacheKey writeLockQueued)
INTENRAL:
Used to set the object that the merge manager is waiting on, in order to acquire locks
If this value is null then the merge manager is not waiting on any locks.
|
boolean |
shouldCascadeAllParts()
Flag used to determine if all parts should be cascaded
|
boolean |
shouldCascadeByMapping()
Flag used to determine that the mappings should be checked for
cascade requirements.
|
boolean |
shouldCascadeParts()
Flag used to determine if any parts should be cascaded
|
boolean |
shouldCascadePrivateParts()
Flag used to determine if any private parts should be cascaded
|
boolean |
shouldCascadeReferences()
Refreshes are based on the objects row, so all attributes of the object must be refreshed.
|
boolean |
shouldForceCascade()
This is used to cascade merge even if a clone is already registered.
|
boolean |
shouldMergeChangesIntoDistributedCache()
INTERNAL:
This happens when changes from an UnitOfWork is propagated to a distributed class.
|
boolean |
shouldMergeCloneIntoWorkingCopy()
This can be used by the user for merging clones from RMI into the unit of work.
|
boolean |
shouldMergeCloneWithReferencesIntoWorkingCopy()
This can be used by the user for merging remote EJB objects into the unit of work.
|
boolean |
shouldMergeOriginalIntoWorkingCopy()
This is used to revert changes to objects, or during refreshes.
|
boolean |
shouldMergeWorkingCopyIntoBackup()
This is used during the unit of work commit to merge changes into the parent.
|
boolean |
shouldMergeWorkingCopyIntoOriginal()
This is used during the unit of work commit to merge changes into the parent.
|
boolean |
shouldMergeWorkingCopyIntoRemote()
INTERNAL:
This happens when serialized remote unit of work has to be merged with local remote unit of work.
|
boolean |
shouldRefreshRemoteObject()
INTERNAL:
This is used to refresh objects on the remote session
|
protected AbstractSession session
protected IdentityHashtable objectDescriptors
protected IdentityHashtable objectsAlreadyMerged
protected IdentityHashtable mergedNewObjects
protected ArrayList acquiredLocks
protected CacheKey writeLockQueued
protected LinkedNode queueNode
protected int mergePolicy
protected static final int WORKING_COPY_INTO_ORIGINAL
protected static final int ORIGINAL_INTO_WORKING_COPY
protected static final int CLONE_INTO_WORKING_COPY
protected static final int WORKING_COPY_INTO_REMOTE
protected static final int REFRESH_REMOTE_OBJECT
protected static final int CHANGES_INTO_DISTRIBUTED_CACHE
protected static final int CLONE_WITH_REFS_INTO_WORKING_COPY
protected static final int WORKING_COPY_INTO_BACKUP
protected int cascadePolicy
public static final int NO_CASCADE
public static final int CASCADE_PRIVATE_PARTS
public static final int CASCADE_ALL_PARTS
public static final int CASCADE_BY_MAPPING
protected long systemTime
public static boolean LOCK_ON_MERGE
protected boolean forceCascade
public MergeManager(AbstractSession session)
protected IdentityHashtable buildIdentitySet(Object container, ContainerPolicy containerPolicy, boolean keyByTarget)
public void cascadeAllParts()
public void cascadePrivateParts()
public void dontCascadeParts()
public ArrayList getAcquiredLocks()
public int getCascadePolicy()
protected int getMergePolicy()
public IdentityHashtable getObjectDescriptors()
public IdentityHashtable getObjectsAlreadyMerged()
public LinkedNode getQueueNode()
public AbstractSession getSession()
public long getSystemTime()
public Object getTargetVersionOfSourceObject(Object source)
public CacheKey getWriteLockQueued()
public Object mergeChanges(Object object, ObjectChangeSet objectChangeSet) throws ValidationException
ValidationException
public void mergeChangesFromChangeSet(UnitOfWorkChangeSet uowChangeSet)
public boolean mergeChangesInCollection(Object source, Object target, Object backup, DatabaseMapping mapping)
protected Object mergeChangesOfCloneIntoWorkingCopy(Object rmiClone)
protected Object mergeChangesOfOriginalIntoWorkingCopy(Object clone)
protected Object mergeChangesOfWorkingCopyIntoOriginal(Object clone, ObjectChangeSet objectChangeSet)
public void mergeCloneIntoWorkingCopy()
public void mergeCloneWithReferencesIntoWorkingCopy()
public void mergeIntoDistributedCache()
public Object mergeNewObjectIntoCache(ObjectChangeSet changeSet)
public void mergeOriginalIntoWorkingCopy()
public void mergeWorkingCopyIntoBackup()
public void mergeWorkingCopyIntoOriginal()
public void mergeWorkingCopyIntoRemote()
public void refreshRemoteObject()
protected Object registerObjectForMergeCloneIntoWorkingCopy(Object clone)
public void registerRemovedNewObjectIfRequired(Object removedObject)
public void setCascadePolicy(int cascadePolicy)
protected void setMergePolicy(int mergePolicy)
public void setForceCascade(boolean forceCascade)
public void setObjectDescriptors(IdentityHashtable objectDescriptors)
protected void setObjectsAlreadyMerged(IdentityHashtable objectsAlreadyMerged)
public void setQueueNode(LinkedNode node)
protected void setSession(AbstractSession session)
public void setWriteLockQueued(CacheKey writeLockQueued)
public boolean shouldCascadeByMapping()
public boolean shouldCascadeAllParts()
public boolean shouldCascadeParts()
public boolean shouldCascadePrivateParts()
public boolean shouldCascadeReferences()
public boolean shouldMergeChangesIntoDistributedCache()
public boolean shouldMergeCloneIntoWorkingCopy()
public boolean shouldMergeCloneWithReferencesIntoWorkingCopy()
public boolean shouldMergeOriginalIntoWorkingCopy()
public boolean shouldMergeWorkingCopyIntoBackup()
public boolean shouldMergeWorkingCopyIntoOriginal()
public boolean shouldMergeWorkingCopyIntoRemote()
public boolean shouldRefreshRemoteObject()
public boolean shouldForceCascade()
Copyright © 2024. All rights reserved.