Class ConflictWatcherImpl
java.lang.Object
com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends ObjectType>
voidafterAddObject(@NotNull String oid, @NotNull PrismObject<T> object) voidafterDeleteObject(String oid) <T extends ObjectType>
voidafterGetObject(PrismObject<T> object) voidafterGetVersion(String oid, String currentRepoVersion) voidafterModifyObject(String oid) <T extends ObjectType>
voidbeforeModifyObject(PrismObject<T> object) intWhat is the version we are currently expected?@NotNull StringgetOid()OID of the object this watcher is watching.booleanWas a conflict detected on the object by this watcher?booleantrueif the watcher was initialized, so it actually detects the conflicts.booleanvoidsetExpectedVersion(String version) Tells the watcher to expect given version of the object being watched.toString()
-
Constructor Details
-
ConflictWatcherImpl
-
-
Method Details
-
afterAddObject
public <T extends ObjectType> void afterAddObject(@NotNull @NotNull String oid, @NotNull @NotNull PrismObject<T> object) -
afterDeleteObject
-
beforeModifyObject
-
afterModifyObject
-
afterGetVersion
-
afterGetObject
-
getOid
Description copied from interface:ConflictWatcherOID of the object this watcher is watching.- Specified by:
getOidin interfaceConflictWatcher
-
hasConflict
public boolean hasConflict()Description copied from interface:ConflictWatcherWas a conflict detected on the object by this watcher?- Specified by:
hasConflictin interfaceConflictWatcher
-
isInitialized
public boolean isInitialized()Description copied from interface:ConflictWatchertrueif the watcher was initialized, so it actually detects the conflicts.- Specified by:
isInitializedin interfaceConflictWatcher
-
getExpectedVersion
public int getExpectedVersion()Description copied from interface:ConflictWatcherWhat is the version we are currently expected? Relevant only ifConflictWatcher.isInitialized()istrue. 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:
getExpectedVersionin interfaceConflictWatcher
-
isObjectDeleted
public boolean isObjectDeleted() -
setExpectedVersion
Description copied from interface:ConflictWatcherTells 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:
setExpectedVersionin interfaceConflictWatcher
-
toString
-