DeferredChangeDetectionPolicypublic class DeferredChangeDetectionPolicy extends Object implements ObjectChangePolicy, SerializablePUBLIC:
A DeferredChangeDetectionPolicy defers all change detection to the UnitOfWork's
change detection process. Essentially, the calculateChanges() method will run
for all objects in a UnitOfWork. This is the default ObjectChangePolicy. |
Methods Summary |
---|
public java.lang.Object | buildBackupClone(java.lang.Object clone, oracle.toplink.essentials.internal.descriptors.ObjectBuilder builder, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow)INTERNAL:
Build back up clone. Used if clone is new because listener should not be set.
return builder.buildBackupClone(clone, uow);
| public oracle.toplink.essentials.internal.sessions.ObjectChangeSet | calculateChanges(java.lang.Object clone, java.lang.Object backUp, oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor, boolean shouldRiseEvent)INTERNAL:
calculateChanges creates a change set for a particular object. In DeferredChangeDetectionPolicy
all mappings will be compared against a backup copy of the object.
boolean isNew = ((backUp == null) || ((((UnitOfWorkImpl)session).isObjectNew(clone)) && (!descriptor.isAggregateDescriptor())));
// PERF: Avoid events if no listeners.
if (descriptor.getEventManager().hasAnyEventListeners() && shouldRiseEvent) {
// The query is built for compatability to old event mechanism.
WriteObjectQuery writeQuery = new WriteObjectQuery(clone.getClass());
writeQuery.setObject(clone);
writeQuery.setBackupClone(backUp);
writeQuery.setSession(session);
writeQuery.setDescriptor(descriptor);
descriptor.getEventManager().executeEvent(new DescriptorEvent(DescriptorEventManager.PreWriteEvent, writeQuery));
if (isNew) {
descriptor.getEventManager().executeEvent(new DescriptorEvent(DescriptorEventManager.PreInsertEvent, writeQuery));
} else {
descriptor.getEventManager().executeEvent(new DescriptorEvent(DescriptorEventManager.PreUpdateEvent, writeQuery));
}
}
ObjectChangeSet changes = createObjectChangeSet(clone, backUp, changeSet, isNew, session, descriptor);
changes.setShouldModifyVersionField((Boolean)((UnitOfWorkImpl)session).getOptimisticReadLockObjects().get(clone));
if (changes.hasChanges() || changes.hasForcedChanges()) {
return changes;
}
return null;
| public void | clearChanges(java.lang.Object object, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
This is a place holder for reseting the listener on one of the subclasses
| public oracle.toplink.essentials.internal.sessions.ObjectChangeSet | createObjectChangeSet(java.lang.Object clone, java.lang.Object backUp, oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
Create ObjectChangeSet
return this.createObjectChangeSetThroughComparison(clone, backUp, changeSet, isNew, session, descriptor);
| public oracle.toplink.essentials.internal.sessions.ObjectChangeSet | createObjectChangeSetThroughComparison(java.lang.Object clone, java.lang.Object backUp, oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
Create ObjectChangeSet
ObjectBuilder builder = descriptor.getObjectBuilder();
ObjectChangeSet changes = builder.createObjectChangeSet(clone, changeSet, isNew, session);
// The following code deals with reads that force changes to the flag associated with optimistic locking.
if ((descriptor.usesOptimisticLocking()) && (changes.getPrimaryKeys() != null)) {
changes.setOptimisticLockingPolicyAndInitialWriteLockValue(descriptor.getOptimisticLockingPolicy(), session);
}
// PERF: Avoid synchronized enumerator as is concurrency bottleneck.
Vector mappings = descriptor.getMappings();
int mappingsSize = mappings.size();
for (int index = 0; index < mappingsSize; index++) {
DatabaseMapping mapping = (DatabaseMapping)mappings.get(index);
changes.addChange(mapping.compareForChange(clone, backUp, changes, session));
}
return changes;
| public void | dissableEventProcessing(java.lang.Object changeTracker)INTERNAL:
This method is used to dissable changetracking temporarily
//no-op
| public void | enableEventProcessing(java.lang.Object changeTracker)INTERNAL:
This method is used to enable changetracking temporarily
//no-op
| public void | initialize(oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
initialize the Policy
//do nothing
| public boolean | isAttributeChangeTrackingPolicy()Used to track instances of the change policies without doing an instance of check
return false;
| public boolean | isDeferredChangeDetectionPolicy()Used to track instances of the change policies without doing an instance of check
return true;
| public boolean | isObjectChangeTrackingPolicy()Used to track instances of the change policies without doing an instance of check
return false;
| public void | raiseInternalPropertyChangeEvent(java.lang.Object source, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)INTERNAL:
This may cause a property change event to be raised to a listner in the case that a listener exists.
If there is no listener then this call is a no-op
//no-op
| public void | revertChanges(java.lang.Object clone, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.internal.helper.IdentityHashtable cloneMapping)INTERNAL:
This method is used to revert an object within the unit of work
cloneMapping.put(clone, buildBackupClone(clone, descriptor.getObjectBuilder(), uow));
clearChanges(clone, uow, descriptor);
| public void | setAggregateChangeListener(java.lang.Object parent, java.lang.Object aggregate, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor, java.lang.String mappingAttribute)INTERNAL:
Assign Changelistner to an aggregate object
//no-op
| public void | setChangeListener(java.lang.Object clone, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
Set ChangeListener for the clone
//no-op
| public void | setChangeSetOnListener(oracle.toplink.essentials.internal.sessions.ObjectChangeSet objectChangeSet, java.lang.Object clone)INTERNAL:
Set the ObjectChangeSet on the Listener, initially used for aggregate support
//no-op
| public boolean | shouldCompareForChange(java.lang.Object object, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl unitOfWork, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
Return true if the Object should be compared, false otherwise. In DeferredChangeDetectionPolicy,
true is always returned since always allow the UnitOfWork to calculate changes.
return true;
| public void | updateWithChanges(java.lang.Object clone, oracle.toplink.essentials.internal.sessions.ObjectChangeSet objectChangeSet, oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl uow, oracle.toplink.essentials.descriptors.ClassDescriptor descriptor)INTERNAL:
Clear changes in the ChangeListener of the clone
if (objectChangeSet == null) {
return;
}
Object backupClone = uow.getCloneMapping().get(clone);
if (backupClone != null) {
MergeManager mergeManager = new MergeManager(uow);
mergeManager.setCascadePolicy(MergeManager.NO_CASCADE);
descriptor.getObjectBuilder().mergeChangesIntoObject(backupClone, objectChangeSet, clone, mergeManager);
}
clearChanges(clone, uow, descriptor);
|
|