Class ConflictWatcherImpl

java.lang.Object
com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl
All Implemented Interfaces:
ConflictWatcher

public class ConflictWatcherImpl extends Object implements ConflictWatcher
Detects write-write conflicts on objects by tracking expected object versions, like this: - After successful ADD and MODIFY operation, the expected version is updated (ADD sets it; MODIFY increases it) - Before MODIFY operation, it is checked that the expected version matches the current version in the repository. This object is local to the thread that uses it. This means that if a different thread modifies the object in the meanwhile, the current version in the repository will no longer match the expected version (on MODIFY operation start) and so the conflict will be detected. NOTE: This object does not prevent conflicting changes. It just detects them.
  • Constructor Details

    • ConflictWatcherImpl

      public ConflictWatcherImpl(@NotNull @NotNull String oid)
  • Method Details

    • afterAddObject

      public <T extends ObjectType> void afterAddObject(@NotNull @NotNull String oid, @NotNull @NotNull PrismObject<T> object)
    • afterDeleteObject

      public void afterDeleteObject(String oid)
    • beforeModifyObject

      public <T extends ObjectType> void beforeModifyObject(PrismObject<T> object)
    • afterModifyObject

      public void afterModifyObject(String oid)
    • afterGetVersion

      public void afterGetVersion(String oid, String currentRepoVersion)
    • afterGetObject

      public <T extends ObjectType> void afterGetObject(PrismObject<T> object)
    • getOid

      @NotNull public @NotNull String getOid()
      Description copied from interface: ConflictWatcher
      OID of the object this watcher is watching.
      Specified by:
      getOid in interface ConflictWatcher
    • hasConflict

      public boolean hasConflict()
      Description copied from interface: ConflictWatcher
      Was a conflict detected on the object by this watcher?
      Specified by:
      hasConflict in interface ConflictWatcher
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: ConflictWatcher
      true if the watcher was initialized, so it actually detects the conflicts.
      Specified by:
      isInitialized in interface ConflictWatcher
    • getExpectedVersion

      public int getExpectedVersion()
      Description copied from interface: ConflictWatcher
      What is the version we are currently expected? Relevant only if ConflictWatcher.isInitialized() is true. NOTE: This is a bit of encapsulation breakage. The conflict detection may be based on things other that the object version. However, for some reason, we (probably temporarily) need this information.
      Specified by:
      getExpectedVersion in interface ConflictWatcher
    • isObjectDeleted

      public boolean isObjectDeleted()
    • setExpectedVersion

      public void setExpectedVersion(String version)
      Description copied from interface: ConflictWatcher
      Tells the watcher to expect given version of the object being watched. Calling this method is optional: If expected version is not provided, it will be determined automatically e.g. on the first MODIFY operation.
      Specified by:
      setExpectedVersion in interface ConflictWatcher
    • toString

      public String toString()
      Overrides:
      toString in class Object