Class DeferredChangeDetectionPolicy

  • All Implemented Interfaces:
    java.io.Serializable, ObjectChangePolicy
    Direct Known Subclasses:
    ObjectChangeTrackingPolicy

    public class DeferredChangeDetectionPolicy
    extends java.lang.Object
    implements ObjectChangePolicy, java.io.Serializable
    PUBLIC: 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 unless weaving is used.
    Author:
    Tom Ware
    See Also:
    Serialized Form
    • Constructor Detail

      • DeferredChangeDetectionPolicy

        public DeferredChangeDetectionPolicy()
    • Method Detail

      • calculateChangesForNewObject

        public ObjectChangeSet calculateChangesForNewObject​(java.lang.Object clone,
                                                            UnitOfWorkChangeSet changeSet,
                                                            UnitOfWorkImpl unitOfWork,
                                                            ClassDescriptor descriptor,
                                                            boolean shouldRaiseEvent)
        INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
        Specified by:
        calculateChangesForNewObject in interface ObjectChangePolicy
        Parameters:
        clone - the Object to compute a change set for
        changeSet - the change set to add changes to
        unitOfWork - the current session
        descriptor - the descriptor for this object
        shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
        Returns:
        ObjectChangeSet an object change set describing the changes to this object
      • calculateChangesForExistingObject

        public ObjectChangeSet calculateChangesForExistingObject​(java.lang.Object clone,
                                                                 UnitOfWorkChangeSet changeSet,
                                                                 UnitOfWorkImpl unitOfWork,
                                                                 ClassDescriptor descriptor,
                                                                 boolean shouldRaiseEvent)
        INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
        Specified by:
        calculateChangesForExistingObject in interface ObjectChangePolicy
        Parameters:
        clone - the Object to compute a change set for
        changeSet - the change set to add changes to
        unitOfWork - the current session
        descriptor - the descriptor for this object
        shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
        Returns:
        ObjectChangeSet an object change set describing the changes to this object
      • calculateChanges

        public ObjectChangeSet calculateChanges​(java.lang.Object clone,
                                                java.lang.Object backUp,
                                                boolean isNew,
                                                UnitOfWorkChangeSet changeSet,
                                                UnitOfWorkImpl unitOfWork,
                                                ClassDescriptor descriptor,
                                                boolean shouldRaiseEvent)
        INTERNAL: calculateChanges creates a change set for a particular object. In DeferredChangeDetectionPolicy all mappings will be compared against a backup copy of the object.
        Specified by:
        calculateChanges in interface ObjectChangePolicy
        Parameters:
        clone - the Object to compute a change set for
        backUp - the old version of the object to use for comparison
        changeSet - the change set to add changes to
        unitOfWork - the current session
        descriptor - the descriptor for this object
        shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
        isNew - determines if the object is new
        Returns:
        an object change set describing the changes to this object
      • dissableEventProcessing

        public void dissableEventProcessing​(java.lang.Object changeTracker)
        INTERNAL: This method is used to disable changetracking temporarily
        Specified by:
        dissableEventProcessing in interface ObjectChangePolicy
      • enableEventProcessing

        public void enableEventProcessing​(java.lang.Object changeTracker)
        INTERNAL: This method is used to enable changetracking temporarily
        Specified by:
        enableEventProcessing in interface ObjectChangePolicy
      • shouldCompareExistingObjectForChange

        public boolean shouldCompareExistingObjectForChange​(java.lang.Object object,
                                                            UnitOfWorkImpl unitOfWork,
                                                            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.
        Specified by:
        shouldCompareExistingObjectForChange in interface ObjectChangePolicy
        Parameters:
        object - the object that will be compared
        unitOfWork - the active unitOfWork
        descriptor - the descriptor for the current object
      • setChangeSetOnListener

        public void setChangeSetOnListener​(ObjectChangeSet objectChangeSet,
                                           java.lang.Object clone)
        INTERNAL: Set the ObjectChangeSet on the Listener, initially used for aggregate support
        Specified by:
        setChangeSetOnListener in interface ObjectChangePolicy
      • raiseInternalPropertyChangeEvent

        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 listener in the case that a listener exists. If there is no listener then this call is a no-op
        Specified by:
        raiseInternalPropertyChangeEvent in interface ObjectChangePolicy
      • revertChanges

        public void revertChanges​(java.lang.Object clone,
                                  ClassDescriptor descriptor,
                                  UnitOfWorkImpl uow,
                                  java.util.Map cloneMapping,
                                  boolean forRefresh)
        INTERNAL: This method is used to revert an object within the unit of work
        Specified by:
        revertChanges in interface ObjectChangePolicy
        Parameters:
        cloneMapping - may not be the same as what is in the uow
      • isDeferredChangeDetectionPolicy

        public boolean isDeferredChangeDetectionPolicy()
        Used to track instances of the change policies without doing an instance of check
        Specified by:
        isDeferredChangeDetectionPolicy in interface ObjectChangePolicy
      • isObjectChangeTrackingPolicy

        public boolean isObjectChangeTrackingPolicy()
        Used to track instances of the change policies without doing an instance of check
        Specified by:
        isObjectChangeTrackingPolicy in interface ObjectChangePolicy
      • isAttributeChangeTrackingPolicy

        public boolean isAttributeChangeTrackingPolicy()
        Used to track instances of the change policies without doing an instance of check
        Specified by:
        isAttributeChangeTrackingPolicy in interface ObjectChangePolicy